[git commit] lineedit: fix PS1='\W' for root directory
Denys Vlasenko
vda.linux at googlemail.com
Sat Nov 8 06:42:34 UTC 2025
commit: https://git.busybox.net/busybox/commit/?id=8cafd7a908347a584261ee630fab2ba183273a86
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
'\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 at pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
libbb/lineedit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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:
More information about the busybox-cvs
mailing list