From b30c60a9786a1608211a96755996bd6c02951a27 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 27 Jul 2017 10:48:30 +0100 Subject: Allow PREFER_APPLETS and SH_STANDALONE to be set separately Upstream BusyBox allows PREFER_APPLETS and SH_STANDALONE to be set independently. Allow such configurations to work in busybox-w32. --- debianutils/which.c | 5 +++-- win32/process.c | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/debianutils/which.c b/debianutils/which.c index 491557167..23a481438 100644 --- a/debianutils/which.c +++ b/debianutils/which.c @@ -45,8 +45,9 @@ int which_main(int argc UNUSED_PARAM, char **argv) int missing = 1; char *p; -#if ENABLE_FEATURE_PREFER_APPLETS - if (find_applet_by_name(*argv) >= 0 || strcmp(*argv, "busybox") == 0) { +#if ENABLE_FEATURE_SH_STANDALONE + if (find_applet_by_name(*argv) >= 0 || + is_prefixed_with(*argv, "busybox")) { missing = 0; puts(*argv); if (!option_mask32) /* -a not set */ diff --git a/win32/process.c b/win32/process.c index 6b579637d..4190c78f8 100644 --- a/win32/process.c +++ b/win32/process.c @@ -235,6 +235,7 @@ spawnveq(int mode, const char *path, const char *const *argv, const char *const return ret; } +#if ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE static intptr_t mingw_spawn_applet(int mode, const char *const *argv, @@ -242,6 +243,7 @@ mingw_spawn_applet(int mode, { return spawnveq(mode, bb_busybox_exec_path, argv, envp); } +#endif static intptr_t mingw_spawn_interpreter(int mode, const char *prog, const char *const *argv, const char *const *envp) @@ -264,11 +266,13 @@ mingw_spawn_interpreter(int mode, const char *prog, const char *const *argv, con memcpy(new_argv+nopts+2, argv+1, sizeof(*argv)*argc); new_argv[nopts+1] = prog; /* pass absolute path */ - if (ENABLE_FEATURE_PREFER_APPLETS && find_applet_by_name(interpr) >= 0) { +#if ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE + if (find_applet_by_name(interpr) >= 0) { new_argv[0] = interpr; ret = mingw_spawn_applet(mode, new_argv, envp); - } - else { + } else +#endif + { char *path = xstrdup(getenv("PATH")); char *tmp = path; char *iprog = find_executable(interpr, &tmp); @@ -292,10 +296,12 @@ mingw_spawn_1(int mode, const char *cmd, const char *const *argv, const char *co { intptr_t ret; - if (ENABLE_FEATURE_PREFER_APPLETS && - find_applet_by_name(cmd) >= 0) +#if ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE + if (find_applet_by_name(cmd) >= 0) return mingw_spawn_applet(mode, argv, envp); - else if (is_absolute_path(cmd)) + else +#endif + if (is_absolute_path(cmd)) return mingw_spawn_interpreter(mode, cmd, argv, envp); else { char *tmp, *path = getenv("PATH"); -- cgit v1.2.3-55-g6feb