diff options
author | Ron Yorston <rmy@pobox.com> | 2023-08-17 15:09:14 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-08-17 15:09:14 +0100 |
commit | 5c1a3b00e235da31b2c73bae18aa5622d820b68a (patch) | |
tree | 4f72b3452418875d684978c0edc2507ede14272b | |
parent | 460463c81f6f7eac4a4376ac7cae9ace715da89e (diff) | |
download | busybox-w32-5c1a3b00e235da31b2c73bae18aa5622d820b68a.tar.gz busybox-w32-5c1a3b00e235da31b2c73bae18aa5622d820b68a.tar.bz2 busybox-w32-5c1a3b00e235da31b2c73bae18aa5622d820b68a.zip |
ash: detect native Windows environment on WineFRP-5181-g5c1a3b00e
The shell detected a native Windows environment by checking for a
mixed-case 'Path' environment variable. This has always worked on
Windows but recent versions of Wine have a 'PATH' environment
variable.
Check also for 'ComSpec'.
Costs 24-48 bytes.
-rw-r--r-- | shell/ash.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c index 5c4a3073a..41bf45734 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -15801,6 +15801,23 @@ static void setvar_if_unset(const char *key, const char *value) | |||
15801 | } | 15801 | } |
15802 | #endif | 15802 | #endif |
15803 | 15803 | ||
15804 | #if ENABLE_PLATFORM_MINGW32 | ||
15805 | static int mixed_case_special_name(const char *envp) | ||
15806 | { | ||
15807 | const char *names = "PATH=\0""COMSPEC=\0"; | ||
15808 | const char *n; | ||
15809 | |||
15810 | for (n = names; *n; ) { | ||
15811 | if (is_prefixed_with_case(envp, n) && !is_prefixed_with(envp, n)) { | ||
15812 | return TRUE; | ||
15813 | } | ||
15814 | while (*n++) | ||
15815 | ; | ||
15816 | } | ||
15817 | return FALSE; | ||
15818 | } | ||
15819 | #endif | ||
15820 | |||
15804 | /* Don't inline: conserve stack of caller from having our locals too */ | 15821 | /* Don't inline: conserve stack of caller from having our locals too */ |
15805 | static NOINLINE void | 15822 | static NOINLINE void |
15806 | init(void) | 15823 | init(void) |
@@ -15834,8 +15851,7 @@ init(void) | |||
15834 | * because it appears first. | 15851 | * because it appears first. |
15835 | */ | 15852 | */ |
15836 | for (envp = environ; envp && *envp; envp++) { | 15853 | for (envp = environ; envp && *envp; envp++) { |
15837 | if (is_prefixed_with_case(*envp, "PATH=") && | 15854 | if (mixed_case_special_name(*envp)) { |
15838 | !is_prefixed_with(*envp, "PATH=")) { | ||
15839 | break; | 15855 | break; |
15840 | } | 15856 | } |
15841 | } | 15857 | } |