From 575581082befff0e049ef67fa36bbdd2ca737e29 Mon Sep 17 00:00:00 2001 From: Ron Yorston 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. --- shell/ash.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 0b41e7931..3bbfbd694 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -14584,10 +14584,13 @@ init(void) } } - /* some initialisation normally performed at login */ + /* Initialise some variables normally set at login, but + * only if someone hasn't already set them. */ pw = xgetpwuid(getuid()); - setup_environment(pw->pw_shell, - SETUP_ENV_CHANGEENV|SETUP_ENV_NO_CHDIR, pw); + if (!getenv("USER")) xsetenv("USER", pw->pw_name); + if (!getenv("LOGNAME")) xsetenv("LOGNAME", pw->pw_name); + if (!getenv("HOME")) xsetenv("HOME", pw->pw_dir); + if (!getenv("SHELL")) xsetenv("SHELL", DEFAULT_SHELL); } #endif for (envp = environ; envp && *envp; envp++) { -- cgit v1.2.3-55-g6feb