[PATCH] shell/lash.c: set environment variable
Shaun Jackman
sjackman at gmail.com
Fri Apr 21 17:52:36 UTC 2006
This patch allows setting an environment variable without an explicit
`export' statement. I understand there's a moratorium of features on
lash, but I consider 'foo=bar' a fairly basic and necessary syntax. On
my ARM7 system this patch adds 32 bytes to the .text section.
Cheers,
Shaun
2006-04-21 Shaun Jackman <sjackman at gmail.com>
* shell/lash.c (pseudo_exec): Allow setting an environment
variable without an explicit 'export'.
--- shell/lash.c 2b6a5734121d4cecda4cd49e644666a1c7bff365
+++ shell/lash.c a4e70a7df8005ac54581bc78f626b770c85ee767
@@ -1233,6 +1233,12 @@
char *name;
#endif
+ /* Check if the command sets an environment variable. */
+ if( strchr(child->argv[0], '=') != NULL ) {
+ child->argv[1] = child->argv[0];
+ _exit(builtin_export(child));
+ }
+
/* Check if the command matches any of the non-forking builtins.
* Depending on context, this might be redundant. But it's
* easier to waste a few CPU cycles than it is to figure out
-------------- next part --------------
2006-04-21 Shaun Jackman <sjackman at gmail.com>
* shell/lash.c (pseudo_exec): Allow setting an environment
variable without an explicit 'export'.
--- shell/lash.c 2b6a5734121d4cecda4cd49e644666a1c7bff365
+++ shell/lash.c a4e70a7df8005ac54581bc78f626b770c85ee767
@@ -1233,6 +1233,12 @@
char *name;
#endif
+ /* Check if the command sets an environment variable. */
+ if( strchr(child->argv[0], '=') != NULL ) {
+ child->argv[1] = child->argv[0];
+ _exit(builtin_export(child));
+ }
+
/* Check if the command matches any of the non-forking builtins.
* Depending on context, this might be redundant. But it's
* easier to waste a few CPU cycles than it is to figure out
More information about the busybox
mailing list