diff options
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/ash.c | 46 |
1 files changed, 8 insertions, 38 deletions
diff --git a/shell/ash.c b/shell/ash.c index d2c88c4bc..ad77689e7 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
| @@ -15885,30 +15885,6 @@ static void setvar_if_unset(const char *key, const char *value) | |||
| 15885 | } | 15885 | } |
| 15886 | #endif | 15886 | #endif |
| 15887 | 15887 | ||
| 15888 | #if ENABLE_PLATFORM_MINGW32 | ||
| 15889 | /* | ||
| 15890 | * Detect if the environment contains certain mixed-case names: | ||
| 15891 | * | ||
| 15892 | * Path is present in a standard Windows environment | ||
| 15893 | * ComSpec is present in WINE | ||
| 15894 | * ProgramData is present in Cygwin/MSYS2 | ||
| 15895 | */ | ||
| 15896 | static int mixed_case_special_name(const char *envp) | ||
| 15897 | { | ||
| 15898 | const char *names = "PATH=\0""COMSPEC=\0""PROGRAMDATA=\0"; | ||
| 15899 | const char *n; | ||
| 15900 | |||
| 15901 | for (n = names; *n; ) { | ||
| 15902 | if (is_prefixed_with_case(envp, n) && !is_prefixed_with(envp, n)) { | ||
| 15903 | return TRUE; | ||
| 15904 | } | ||
| 15905 | while (*n++) | ||
| 15906 | ; | ||
| 15907 | } | ||
| 15908 | return FALSE; | ||
| 15909 | } | ||
| 15910 | #endif | ||
| 15911 | |||
| 15912 | /* Don't inline: conserve stack of caller from having our locals too */ | 15888 | /* Don't inline: conserve stack of caller from having our locals too */ |
| 15913 | static NOINLINE void | 15889 | static NOINLINE void |
| 15914 | init(void) | 15890 | init(void) |
| @@ -15941,26 +15917,20 @@ init(void) | |||
| 15941 | * We may end up having both Path and PATH. Then Path will be chosen | 15917 | * We may end up having both Path and PATH. Then Path will be chosen |
| 15942 | * because it appears first. | 15918 | * because it appears first. |
| 15943 | */ | 15919 | */ |
| 15944 | for (envp = environ; envp && *envp; envp++) { | 15920 | if (windows_env()) { |
| 15945 | if (mixed_case_special_name(*envp)) { | ||
| 15946 | /* mintty sets HOME: unset it */ | ||
| 15947 | const char *tty = getenv("TERM_PROGRAM"); | ||
| 15948 | if (tty && strcmp(tty, "mintty") == 0) { | ||
| 15949 | unsetenv("HOME"); | ||
| 15950 | } | ||
| 15951 | break; | ||
| 15952 | } | ||
| 15953 | } | ||
| 15954 | |||
| 15955 | if (envp && *envp) { | ||
| 15956 | /* | 15921 | /* |
| 15957 | * If we get here it's because the environment contains a path | 15922 | * If we get here it's because the environment suggests we |
| 15958 | * variable called something other than PATH. This suggests we | ||
| 15959 | * haven't been invoked from an earlier instance of BusyBox. | 15923 | * haven't been invoked from an earlier instance of BusyBox. |
| 15960 | */ | 15924 | */ |
| 15961 | char *start, *end; | 15925 | char *start, *end; |
| 15962 | struct passwd *pw; | 15926 | struct passwd *pw; |
| 15963 | 15927 | ||
| 15928 | /* mintty sets HOME: unset it */ | ||
| 15929 | const char *tty = getenv("TERM_PROGRAM"); | ||
| 15930 | if (tty && strcmp(tty, "mintty") == 0) { | ||
| 15931 | unsetenv("HOME"); | ||
| 15932 | } | ||
| 15933 | |||
| 15964 | import = VIMPORT; | 15934 | import = VIMPORT; |
| 15965 | for (envp = environ; envp && *envp; envp++) { | 15935 | for (envp = environ; envp && *envp; envp++) { |
| 15966 | if (!(end=strchr(*envp, '='))) | 15936 | if (!(end=strchr(*envp, '='))) |
