From f9b753e70101ddd708841cc942e2072e1163a260 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 15 Mar 2019 15:53:53 +0000 Subject: ash: set current working directory on startup When the shell starts behave as though the user had manually changed to the current working directory of the process, but only if it's an interactive, non-login shell and the '-d' flag isn't present. This gives more consistent behaviour when the shell is started in a drive mapped to a network share or a symlinked directory. This completes the changes requested in GitHub issue #148. --- shell/ash.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 4adad65aa..40cb9bce8 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -15009,6 +15009,13 @@ int ash_main(int argc UNUSED_PARAM, char **argv) chdir(dirarg); setpwd(NULL, 0); } + else if (!login_sh && iflag) { + char *cwd = getcwd(NULL, 0); + if (cwd) { + docd(cwd, 0); + free(cwd); + } + } if (title) set_title(title); -- cgit v1.2.3-55-g6feb