From 575581082befff0e049ef67fa36bbdd2ca737e29 Mon Sep 17 00:00:00 2001
From: Ron Yorston <rmy@pobox.com>
Date: Fri, 14 Dec 2018 15:12:52 +0000
Subject: ash: move code from setup_environment()

ash calls setup_environment() but only uses a small amount of its
functionality.  Moving the code into ash itself means we don't
need to customise setup_environment() for WIN32 and can remove
it from the build.
---
 libbb/Kbuild.src          |  2 +-
 libbb/setup_environment.c | 11 -----------
 2 files changed, 1 insertion(+), 12 deletions(-)

(limited to 'libbb')

diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src
index 9323a8968..43ededbea 100644
--- a/libbb/Kbuild.src
+++ b/libbb/Kbuild.src
@@ -66,7 +66,6 @@ lib-y += safe_poll.o
 lib-y += safe_strncpy.o
 lib-y += safe_write.o
 lib-y += securetty.o
-lib-y += setup_environment.o
 lib-y += single_argv.o
 lib-y += skip_whitespace.o
 lib-y += str_tolower.o
@@ -106,6 +105,7 @@ lib-$(CONFIG_PLATFORM_POSIX) += pidfile.o
 lib-$(CONFIG_PLATFORM_POSIX) += print_flags.o
 lib-$(CONFIG_PLATFORM_POSIX) += progress.o
 lib-$(CONFIG_PLATFORM_POSIX) += read_key.o
+lib-$(CONFIG_PLATFORM_POSIX) += setup_environment.o
 lib-$(CONFIG_PLATFORM_POSIX) += signals.o
 lib-$(CONFIG_PLATFORM_POSIX) += simplify_path.o
 lib-$(CONFIG_PLATFORM_POSIX) += speed_table.o
diff --git a/libbb/setup_environment.c b/libbb/setup_environment.c
index c583206f0..f8de44967 100644
--- a/libbb/setup_environment.c
+++ b/libbb/setup_environment.c
@@ -29,14 +29,6 @@
  */
 #include "libbb.h"
 
-#if ENABLE_PLATFORM_MINGW32
-static void xsetenv_if_unset(const char *key, const char *value)
-{
-	if (!getenv(key))
-		xsetenv(key, value);
-}
-#endif
-
 void FAST_FUNC setup_environment(const char *shell, int flags, const struct passwd *pw)
 {
 	if (!shell || !shell[0])
@@ -68,9 +60,6 @@ void FAST_FUNC setup_environment(const char *shell, int flags, const struct pass
 		//xsetenv("HOME",    pw->pw_dir);
 		//xsetenv("SHELL",   shell);
 	} else if (flags & SETUP_ENV_CHANGEENV) {
-#if ENABLE_PLATFORM_MINGW32
-#define xsetenv(k, v) xsetenv_if_unset(k, v)
-#endif
 		/* Set HOME, SHELL, and if not becoming a super-user,
 		 * USER and LOGNAME.  */
 		if (pw->pw_uid) {
-- 
cgit v1.2.3-55-g6feb