aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2002-12-23 10:23:10 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2002-12-23 10:23:10 +0000
commitc00c56e7c8d2446c2c91445afbaad77c3ee72175 (patch)
tree4a8e0edeebcc6fdc3e0a0ced6fe14af0cbdc220d
parent0a65e190f4dafd5850fb3e86df30e88b198bab1e (diff)
downloadbusybox-c00c56e7c8d2446c2c91445afbaad77c3ee72175.tar.gz
Fix STANDALONE_SHELL and ALWAYS_WIN options, last_path_73 by Vladimir N. Oleynik
-rw-r--r--shell/ash.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 696d554a9..97a28b1f5 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -3280,20 +3280,34 @@ static void tryexec(char *cmd, char **argv, char **envp)
int repeated = 0;
#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
+ int flg_bb = 0;
char *name = cmd;
- char **argv_l = argv;
- int argc_l;
#ifdef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN
name = get_last_path_component(name);
+ if(find_applet_by_name(name) != NULL)
+ flg_bb = 1;
+#else
+ if(strchr(name, '/') == NULL && find_applet_by_name(name) != NULL) {
+ flg_bb = 1;
+ }
#endif
- argv_l = envp;
- for (argc_l = 0; *argv_l != NULL; argv_l++, argc_l++)
- putenv(*argv_l);
- argv_l = argv;
- for (argc_l = 0; *argv_l != NULL; argv_l++, argc_l++)
- optind = 1;
- run_applet_by_name(name, argc_l, argv);
+ if(flg_bb) {
+ char **ap;
+ char **new;
+
+ *argv = name;
+ if(strcmp(name, "busybox")) {
+ for (ap = argv; *ap; ap++);
+ ap = new = xmalloc((ap - argv + 2) * sizeof(char *));
+ *ap++ = cmd = "/bin/busybox";
+ while ((*ap++ = *argv++));
+ argv = new;
+ repeated++;
+ } else {
+ cmd = "/bin/busybox";
+ }
+ }
#endif
repeat:
execve(cmd, argv, envp);