diff options
author | Ron Yorston <rmy@pobox.com> | 2017-07-27 10:48:30 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-07-27 11:00:31 +0100 |
commit | b30c60a9786a1608211a96755996bd6c02951a27 (patch) | |
tree | 8b736bca278d245b8d4ddecba98a72347a689e1f | |
parent | 1f01a34ecb0e0fbe01ec6e8ab04256a9a05a3c46 (diff) | |
download | busybox-w32-b30c60a9786a1608211a96755996bd6c02951a27.tar.gz busybox-w32-b30c60a9786a1608211a96755996bd6c02951a27.tar.bz2 busybox-w32-b30c60a9786a1608211a96755996bd6c02951a27.zip |
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.
-rw-r--r-- | debianutils/which.c | 5 | ||||
-rw-r--r-- | 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) | |||
45 | int missing = 1; | 45 | int missing = 1; |
46 | char *p; | 46 | char *p; |
47 | 47 | ||
48 | #if ENABLE_FEATURE_PREFER_APPLETS | 48 | #if ENABLE_FEATURE_SH_STANDALONE |
49 | if (find_applet_by_name(*argv) >= 0 || strcmp(*argv, "busybox") == 0) { | 49 | if (find_applet_by_name(*argv) >= 0 || |
50 | is_prefixed_with(*argv, "busybox")) { | ||
50 | missing = 0; | 51 | missing = 0; |
51 | puts(*argv); | 52 | puts(*argv); |
52 | if (!option_mask32) /* -a not set */ | 53 | 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 | |||
235 | return ret; | 235 | return ret; |
236 | } | 236 | } |
237 | 237 | ||
238 | #if ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE | ||
238 | static intptr_t | 239 | static intptr_t |
239 | mingw_spawn_applet(int mode, | 240 | mingw_spawn_applet(int mode, |
240 | const char *const *argv, | 241 | const char *const *argv, |
@@ -242,6 +243,7 @@ mingw_spawn_applet(int mode, | |||
242 | { | 243 | { |
243 | return spawnveq(mode, bb_busybox_exec_path, argv, envp); | 244 | return spawnveq(mode, bb_busybox_exec_path, argv, envp); |
244 | } | 245 | } |
246 | #endif | ||
245 | 247 | ||
246 | static intptr_t | 248 | static intptr_t |
247 | mingw_spawn_interpreter(int mode, const char *prog, const char *const *argv, const char *const *envp) | 249 | 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 | |||
264 | memcpy(new_argv+nopts+2, argv+1, sizeof(*argv)*argc); | 266 | memcpy(new_argv+nopts+2, argv+1, sizeof(*argv)*argc); |
265 | new_argv[nopts+1] = prog; /* pass absolute path */ | 267 | new_argv[nopts+1] = prog; /* pass absolute path */ |
266 | 268 | ||
267 | if (ENABLE_FEATURE_PREFER_APPLETS && find_applet_by_name(interpr) >= 0) { | 269 | #if ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE |
270 | if (find_applet_by_name(interpr) >= 0) { | ||
268 | new_argv[0] = interpr; | 271 | new_argv[0] = interpr; |
269 | ret = mingw_spawn_applet(mode, new_argv, envp); | 272 | ret = mingw_spawn_applet(mode, new_argv, envp); |
270 | } | 273 | } else |
271 | else { | 274 | #endif |
275 | { | ||
272 | char *path = xstrdup(getenv("PATH")); | 276 | char *path = xstrdup(getenv("PATH")); |
273 | char *tmp = path; | 277 | char *tmp = path; |
274 | char *iprog = find_executable(interpr, &tmp); | 278 | 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 | |||
292 | { | 296 | { |
293 | intptr_t ret; | 297 | intptr_t ret; |
294 | 298 | ||
295 | if (ENABLE_FEATURE_PREFER_APPLETS && | 299 | #if ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE |
296 | find_applet_by_name(cmd) >= 0) | 300 | if (find_applet_by_name(cmd) >= 0) |
297 | return mingw_spawn_applet(mode, argv, envp); | 301 | return mingw_spawn_applet(mode, argv, envp); |
298 | else if (is_absolute_path(cmd)) | 302 | else |
303 | #endif | ||
304 | if (is_absolute_path(cmd)) | ||
299 | return mingw_spawn_interpreter(mode, cmd, argv, envp); | 305 | return mingw_spawn_interpreter(mode, cmd, argv, envp); |
300 | else { | 306 | else { |
301 | char *tmp, *path = getenv("PATH"); | 307 | char *tmp, *path = getenv("PATH"); |