svn commit: trunk/busybox/shell
landley at busybox.net
landley at busybox.net
Tue Jun 13 19:01:38 UTC 2006
Author: landley
Date: 2006-06-13 12:01:30 -0700 (Tue, 13 Jun 2006)
New Revision: 15378
Log:
Patch from Shaun Jackman to detect "name=value" variable assignments. Random
cleanup at the end by me to make some unrelated #ifdefs go away...
Modified:
trunk/busybox/shell/lash.c
Changeset:
Modified: trunk/busybox/shell/lash.c
===================================================================
--- trunk/busybox/shell/lash.c 2006-06-13 18:50:20 UTC (rev 15377)
+++ trunk/busybox/shell/lash.c 2006-06-13 19:01:30 UTC (rev 15378)
@@ -1182,10 +1182,13 @@
static int pseudo_exec(struct child_prog *child)
{
struct built_in_command *x;
-#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
- 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
@@ -1204,7 +1207,7 @@
_exit (x->function(child));
}
}
-#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
+
/* Check if the command matches any busybox internal
* commands ("applets") here. Following discussions from
* November 2000 on busybox at busybox.net, don't use
@@ -1216,17 +1219,15 @@
* /bin/foo invocation will fork and exec /bin/foo, even if
* /bin/foo is a symlink to busybox.
*/
- name = child->argv[0];
- {
- char** argv_l=child->argv;
+ if (ENABLE_FEATURE_SH_STANDALONE_SHELL) {
+ char **argv_l = child->argv;
int argc_l;
- for(argc_l=0;*argv_l!=NULL; argv_l++, argc_l++);
+ for(argc_l=0; *argv_l; argv_l++, argc_l++);
optind = 1;
- run_applet_by_name(name, argc_l, child->argv);
+ run_applet_by_name(child->argv[0], argc_l, child->argv);
}
-#endif
execvp(child->argv[0], child->argv);
More information about the busybox-cvs
mailing list