diff options
-rw-r--r-- | libbb/setup_environment.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libbb/setup_environment.c b/libbb/setup_environment.c index 4258656fe..944ac5538 100644 --- a/libbb/setup_environment.c +++ b/libbb/setup_environment.c | |||
@@ -30,6 +30,14 @@ | |||
30 | 30 | ||
31 | #include "libbb.h" | 31 | #include "libbb.h" |
32 | 32 | ||
33 | #if ENABLE_PLATFORM_MINGW32 | ||
34 | static void xsetenv_if_unset(const char *key, const char *value) | ||
35 | { | ||
36 | if (!getenv(key)) | ||
37 | xsetenv(key, value); | ||
38 | } | ||
39 | #endif | ||
40 | |||
33 | void FAST_FUNC setup_environment(const char *shell, int flags, const struct passwd *pw) | 41 | void FAST_FUNC setup_environment(const char *shell, int flags, const struct passwd *pw) |
34 | { | 42 | { |
35 | if (!shell || !shell[0]) | 43 | if (!shell || !shell[0]) |
@@ -61,6 +69,9 @@ void FAST_FUNC setup_environment(const char *shell, int flags, const struct pass | |||
61 | //xsetenv("HOME", pw->pw_dir); | 69 | //xsetenv("HOME", pw->pw_dir); |
62 | //xsetenv("SHELL", shell); | 70 | //xsetenv("SHELL", shell); |
63 | } else if (flags & SETUP_ENV_CHANGEENV) { | 71 | } else if (flags & SETUP_ENV_CHANGEENV) { |
72 | #if ENABLE_PLATFORM_MINGW32 | ||
73 | #define xsetenv(k, v) xsetenv_if_unset(k, v) | ||
74 | #endif | ||
64 | /* Set HOME, SHELL, and if not becoming a super-user, | 75 | /* Set HOME, SHELL, and if not becoming a super-user, |
65 | * USER and LOGNAME. */ | 76 | * USER and LOGNAME. */ |
66 | if (pw->pw_uid) { | 77 | if (pw->pw_uid) { |