aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/parser.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c
index 26c1362c7d2a..f3cc98d43cb0 100644
--- a/bin/sh/parser.c
+++ b/bin/sh/parser.c
@@ -2014,8 +2014,9 @@ getprompt(void *unused __unused)
gethostname(&ps[i], PROMPTLEN - i);
/* Skip to end of hostname. */
trim = (*fmt == 'h') ? '.' : '\0';
- while ((ps[i+1] != '\0') && (ps[i+1] != trim))
+ while ((ps[i] != '\0') && (ps[i] != trim))
i++;
+ --i;
break;
/*
@@ -2027,7 +2028,7 @@ getprompt(void *unused __unused)
case 'W':
case 'w':
pwd = lookupvar("PWD");
- if (pwd == NULL)
+ if (pwd == NULL || *pwd == '\0')
pwd = "?";
if (*fmt == 'W' &&
*pwd == '/' && pwd[1] != '\0')