diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c index 3a143229e..1b7fa9849 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -14850,6 +14850,14 @@ exitshell(void) | |||
14850 | /* NOTREACHED */ | 14850 | /* NOTREACHED */ |
14851 | } | 14851 | } |
14852 | 14852 | ||
14853 | #if ENABLE_PLATFORM_MINGW32 | ||
14854 | static void xsetenv_if_unset(const char *key, const char *value) | ||
14855 | { | ||
14856 | if (!getenv(key)) | ||
14857 | xsetenv(key, value); | ||
14858 | } | ||
14859 | #endif | ||
14860 | |||
14853 | /* Don't inline: conserve stack of caller from having our locals too */ | 14861 | /* Don't inline: conserve stack of caller from having our locals too */ |
14854 | static NOINLINE void | 14862 | static NOINLINE void |
14855 | init(void) | 14863 | init(void) |
@@ -14943,10 +14951,10 @@ init(void) | |||
14943 | /* Initialise some variables normally set at login, but | 14951 | /* Initialise some variables normally set at login, but |
14944 | * only if someone hasn't already set them. */ | 14952 | * only if someone hasn't already set them. */ |
14945 | pw = xgetpwuid(getuid()); | 14953 | pw = xgetpwuid(getuid()); |
14946 | if (!getenv("USER")) xsetenv("USER", pw->pw_name); | 14954 | xsetenv_if_unset("USER", pw->pw_name); |
14947 | if (!getenv("LOGNAME")) xsetenv("LOGNAME", pw->pw_name); | 14955 | xsetenv_if_unset("LOGNAME", pw->pw_name); |
14948 | if (!getenv("HOME")) xsetenv("HOME", pw->pw_dir); | 14956 | xsetenv_if_unset("HOME", pw->pw_dir); |
14949 | if (!getenv("SHELL")) xsetenv("SHELL", DEFAULT_SHELL); | 14957 | xsetenv_if_unset("SHELL", DEFAULT_SHELL); |
14950 | } | 14958 | } |
14951 | #endif | 14959 | #endif |
14952 | for (envp = environ; envp && *envp; envp++) { | 14960 | for (envp = environ; envp && *envp; envp++) { |