From af41de68901d48753eb73491d54931a99d1a13b5 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 22 Mar 2022 08:12:07 +0000 Subject: ash: let $HOME set home directory of login shell In busybox-w32 the shell option '-l' sets HOME to the user's home directory, as determined by a call to GetUserProfileDirectory(). This is differs from how shells work on Unix, where HOME is usually set by login(1). Allow the user to override this behaviour by setting HOME before starting the shell. If HOME isn't set or contains an empty string the previous behaviour applies. If HOME is set to a non-empty string the user should ensure that it represents a valid absolute path. (GitHub issue #244) --- shell/ash.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index d8f9dba34..e8a1e853c 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -15764,7 +15764,10 @@ int ash_main(int argc UNUSED_PARAM, char **argv) #if ENABLE_PLATFORM_MINGW32 if (!dirarg) { - chdir(xgetpwuid(getuid())->pw_dir); + hp = lookupvar("HOME"); + if (hp == NULL || *hp == '\0') + hp = xgetpwuid(getuid())->pw_dir; + chdir(hp); setpwd(NULL, 0); } #endif -- cgit v1.2.3-55-g6feb