diff options
author | Ron Yorston <rmy@pobox.com> | 2020-06-14 10:17:04 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2020-06-14 10:17:04 +0100 |
commit | f41697493de1a25d0f56930d81cf9560172ce7b7 (patch) | |
tree | 998b60552725808730478c3288f2452a40ffe7b8 | |
parent | b1a5034ca852efe2c24212db77d7b0b2660a687b (diff) | |
download | busybox-w32-f41697493de1a25d0f56930d81cf9560172ce7b7.tar.gz busybox-w32-f41697493de1a25d0f56930d81cf9560172ce7b7.tar.bz2 busybox-w32-f41697493de1a25d0f56930d81cf9560172ce7b7.zip |
win32: enable globbing by default
Change how busybox.exe expands wildcards on the command line.
When globbing is enabled at compile time provide an implementation
of _setargv(), which is run early during startup of C programs. This:
- enables globbing by setting _dowildcard to -1
- checks for the presence of the environment BB_GLOBBING
- if it exists and is set to 0 disables globbing
- if it doesn't exist sets BB_GLOBBING=0 but continues to apply
Windows' globbing in the current process
The consequences of this are:
- When busybox.exe is initially run from a Command Prompt Windows'
globbing is applied;
- Windows' globbing is turned off for future child processes, thus
allowing the shell re-execute busybox.exe without it interfering
with wildcards;
- this behaviour can be overridden by setting BB_GLOBBING explicitly.
Globbing can still be disabled at compile time if required. In that
case BB_GLOBBING has no effect.
With these changes globbing can be enabled by default and BusyBox
will do the right thing in most circumstances.
(See GitHub issues #172 and #189.)
-rw-r--r-- | Config.in | 10 | ||||
-rw-r--r-- | configs/mingw32_defconfig | 4 | ||||
-rw-r--r-- | configs/mingw64_defconfig | 4 | ||||
-rw-r--r-- | libbb/appletlib.c | 5 | ||||
-rw-r--r-- | win32/mingw.c | 18 |
5 files changed, 26 insertions, 15 deletions
@@ -387,15 +387,15 @@ comment 'Settings for MINGW32' | |||
387 | 387 | ||
388 | config GLOBBING | 388 | config GLOBBING |
389 | bool "Allow busybox.exe to expand wildcards" | 389 | bool "Allow busybox.exe to expand wildcards" |
390 | default n | 390 | default y |
391 | depends on PLATFORM_MINGW32 | 391 | depends on PLATFORM_MINGW32 |
392 | help | 392 | help |
393 | In Microsoft Windows expansion of wildcards on the command line | 393 | In Microsoft Windows expansion of wildcards on the command line |
394 | ('globbing') is handled by the C runtime while the BusyBox shell | 394 | ('globbing') is handled by the C runtime while the BusyBox shell |
395 | does its own wildcard expansion. For best results when using the | 395 | does its own wildcard expansion. In most circumstances BusyBox |
396 | shell globbing by the C runtime should be turned off. If you want | 396 | will do the right thing. If it doesn't or if you don't need to |
397 | the BusyBox binary to handle wildcard expansion using the C runtime | 397 | use BusyBox applets from the Windows Command Prompt you can stop |
398 | set this to 'Y'. | 398 | busybox.exe from expanding wildcards by setting this to 'N'. |
399 | 399 | ||
400 | choice | 400 | choice |
401 | prompt "Random number generator" | 401 | prompt "Random number generator" |
diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig index bffe88842..b3dfc0033 100644 --- a/configs/mingw32_defconfig +++ b/configs/mingw32_defconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.32.0.git | 3 | # Busybox version: 1.32.0.git |
4 | # Fri May 29 10:58:25 2020 | 4 | # Sun Jun 14 09:30:06 2020 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | # CONFIG_PLATFORM_POSIX is not set | 7 | # CONFIG_PLATFORM_POSIX is not set |
@@ -43,7 +43,7 @@ CONFIG_BUSYBOX_EXEC_PATH="" | |||
43 | # | 43 | # |
44 | # Settings for MINGW32 | 44 | # Settings for MINGW32 |
45 | # | 45 | # |
46 | # CONFIG_GLOBBING is not set | 46 | CONFIG_GLOBBING=y |
47 | CONFIG_FEATURE_PRNG_SHELL=y | 47 | CONFIG_FEATURE_PRNG_SHELL=y |
48 | # CONFIG_FEATURE_PRNG_ISAAC is not set | 48 | # CONFIG_FEATURE_PRNG_ISAAC is not set |
49 | CONFIG_FEATURE_RESOURCES=y | 49 | CONFIG_FEATURE_RESOURCES=y |
diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig index d0a541162..2410d476d 100644 --- a/configs/mingw64_defconfig +++ b/configs/mingw64_defconfig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.32.0.git | 3 | # Busybox version: 1.32.0.git |
4 | # Fri May 29 10:59:57 2020 | 4 | # Sun Jun 14 09:30:06 2020 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | # CONFIG_PLATFORM_POSIX is not set | 7 | # CONFIG_PLATFORM_POSIX is not set |
@@ -43,7 +43,7 @@ CONFIG_BUSYBOX_EXEC_PATH="" | |||
43 | # | 43 | # |
44 | # Settings for MINGW32 | 44 | # Settings for MINGW32 |
45 | # | 45 | # |
46 | # CONFIG_GLOBBING is not set | 46 | CONFIG_GLOBBING=y |
47 | CONFIG_FEATURE_PRNG_SHELL=y | 47 | CONFIG_FEATURE_PRNG_SHELL=y |
48 | # CONFIG_FEATURE_PRNG_ISAAC is not set | 48 | # CONFIG_FEATURE_PRNG_ISAAC is not set |
49 | CONFIG_FEATURE_RESOURCES=y | 49 | CONFIG_FEATURE_RESOURCES=y |
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 9caa04ac3..8c46d0d1b 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -915,11 +915,6 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) | |||
915 | "\tTo run external program, use full path (/sbin/ip instead of ip).\n" | 915 | "\tTo run external program, use full path (/sbin/ip instead of ip).\n" |
916 | ) | 916 | ) |
917 | "\n" | 917 | "\n" |
918 | #if ENABLE_GLOBBING | ||
919 | "\tSupport for native Windows wildcards is enabled. In some\n" | ||
920 | "\tcases this may result in wildcards being processed twice.\n" | ||
921 | "\n" | ||
922 | #endif | ||
923 | "Currently defined functions:\n" | 918 | "Currently defined functions:\n" |
924 | ); | 919 | ); |
925 | col = 0; | 920 | col = 0; |
diff --git a/win32/mingw.c b/win32/mingw.c index 105b7864d..06b22a2ed 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -10,7 +10,23 @@ | |||
10 | 10 | ||
11 | #if defined(__MINGW64_VERSION_MAJOR) | 11 | #if defined(__MINGW64_VERSION_MAJOR) |
12 | #if ENABLE_GLOBBING | 12 | #if ENABLE_GLOBBING |
13 | int _dowildcard = -1; | 13 | extern int _setargv(void); |
14 | int _setargv(void) | ||
15 | { | ||
16 | extern int _dowildcard; | ||
17 | char *glob; | ||
18 | |||
19 | _dowildcard = -1; | ||
20 | glob = getenv("BB_GLOBBING"); | ||
21 | if (glob) { | ||
22 | if (strcmp(glob, "0") == 0) | ||
23 | _dowildcard = 0; | ||
24 | } | ||
25 | else { | ||
26 | setenv("BB_GLOBBING", "0", TRUE); | ||
27 | } | ||
28 | return 0; | ||
29 | } | ||
14 | #else | 30 | #else |
15 | int _dowildcard = 0; | 31 | int _dowildcard = 0; |
16 | #endif | 32 | #endif |