summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-02 01:43:55 -0500
committerJune McEnroe <june@causal.agency>2019-12-02 01:43:55 -0500
commit097c246fe7e170663e681641781e6c7d3f46b4a6 (patch)
treecc9194451fc3de4e258858aabf30236ef3472b98
parentOnly add existing directories to PATH (diff)
downloadsrc-097c246fe7e170663e681641781e6c7d3f46b4a6.tar.gz
src-097c246fe7e170663e681641781e6c7d3f46b4a6.zip
Fix \? prompt expansion for more than one digit
Diffstat (limited to '')
-rw-r--r--bin/1sh/parser.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/bin/1sh/parser.c b/bin/1sh/parser.c
index 39b36e67..a7b86aab 100644
--- a/bin/1sh/parser.c
+++ b/bin/1sh/parser.c
@@ -2042,10 +2042,12 @@ expandprompt(const char *fmt) {
 				 * Exit status if non-zero.
 				 */
 			case '?':
-				if (exitstatus != 0)
+				if (exitstatus != 0) {
 					snprintf(&ps[i], PROMPTLEN - i, "%d", exitstatus);
-				else
-					i--;
+					while (ps[i] != '\0')
+						i++;
+				}
+				i--;
 				break;
 
 				/*
e='2019-05-12 12:18:31 -0400'>2019-05-12Add T suffix in bitJune McEnroe 2019-05-10Highlight yacc and lex files as CJune McEnroe 2019-05-10Use val instead of suboptargJune McEnroe 2019-05-09Add Parable of the SowerJune McEnroe 2019-05-07Add bit without buildJune McEnroe 2019-05-04Fix MANDIR typoJune McEnroe 2019-05-04Move relay to binJune McEnroe