aboutsummaryrefslogtreecommitdiff
path: root/win32/mingw.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2020-06-14 10:17:04 +0100
committerRon Yorston <rmy@pobox.com>2020-06-14 10:17:04 +0100
commitf41697493de1a25d0f56930d81cf9560172ce7b7 (patch)
tree998b60552725808730478c3288f2452a40ffe7b8 /win32/mingw.c
parentb1a5034ca852efe2c24212db77d7b0b2660a687b (diff)
downloadbusybox-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.)
Diffstat (limited to 'win32/mingw.c')
-rw-r--r--win32/mingw.c18
1 files changed, 17 insertions, 1 deletions
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
13int _dowildcard = -1; 13extern int _setargv(void);
14int _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
15int _dowildcard = 0; 31int _dowildcard = 0;
16#endif 32#endif