summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2025-10-23 12:00:21 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2025-11-08 07:42:34 +0100
commit8cafd7a908347a584261ee630fab2ba183273a86 (patch)
tree82d8e6fac75b29a77650e752f609b080301643fc
parent782e3fc2b4012958d43e964064fd2f2806d46106 (diff)
lineedit: fix PS1='\W' for root directory
'\W' in PS1 returned an empty string for the root directory. bash displays '/' in similar circumstances. Avoid returning an empty string for the directory. function old new delta parse_and_put_prompt 873 883 +10 Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/lineedit.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 10cc0433b..1ca21e924 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -2079,7 +2079,7 @@ static void parse_and_put_prompt(const char *prmt_ptr)
if (c == 'w')
break;
cp = strrchr(pbuf, '/');
- if (cp)
+ if (cp && cp[1])
pbuf = (char*)cp + 1;
break;
// bb_process_escape_sequence does this now: