From c00c56e7c8d2446c2c91445afbaad77c3ee72175 Mon Sep 17 00:00:00 2001 From: Glenn L McGrath Date: Mon, 23 Dec 2002 10:23:10 +0000 Subject: Fix STANDALONE_SHELL and ALWAYS_WIN options, last_path_73 by Vladimir N. Oleynik --- shell/ash.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'shell') 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); -- cgit v1.2.3