Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2022-06-28 15:40:49 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2022-07-03 22:41:38 +0300
commit298ac9507bb6cb932162f863c7b9623c0a37dedb (patch)
tree636d0071ea70b55a58892ac076134ed3f4968b32 /libbb
parent20a4f70ecaad79bb932af09b7317a058872cd867 (diff)
lineedit: get PWD from ash
The line editing code and ash disagree when the current directory is changed to a symbolic link: ~ $ mkdir real ~ $ ln -s real link ~ $ cd link ~/real $ pwd /home/rmyf36/link Note the prompt says we're in ~/real. Bash does: [rmy@random ~]$ cd link [rmy@random link]$ pwd /home/rmyf36/link Ash uses the name supplied by the user while the line editing code calls getcwd(3). The discrepancy can be avoided by fetching the value of PWD from ash. Hush calls getcwd(3) when the directory is changed so there's no disagreement with the line editing code. There is no standard how shells should handle cd'ing into symlinks. function old new delta parse_and_put_prompt 838 869 +31 Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/lineedit.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index b685399f9..697f2a577 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -2035,7 +2035,13 @@ static void parse_and_put_prompt(const char *prmt_ptr)
case 'W': /* basename of cur dir */
if (!cwd_buf) {
const char *home;
+#if ENABLE_SHELL_ASH
+ cwd_buf = state->sh_get_var
+ ? xstrdup(state->sh_get_var("PWD"))
+ : xrealloc_getcwd_or_warn(NULL);
+#else
cwd_buf = xrealloc_getcwd_or_warn(NULL);
+#endif
if (!cwd_buf)
cwd_buf = (char *)bb_msg_unknown;
else if ((home = get_homedir_or_NULL()) != NULL && home[0]) {