summary refs log tree commit diff
path: root/bin/1sh/parser.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-11-20 21:46:01 -0500
committerJune McEnroe <june@causal.agency>2019-11-20 21:46:01 -0500
commitfa44f94313d04afe440f58e233347b8fa4c78605 (patch)
tree692ee0a3769dba34b365b08415e534eeca3cce4d /bin/1sh/parser.c
parentRemove PSlit (diff)
downloadsrc-fa44f94313d04afe440f58e233347b8fa4c78605.tar.gz
src-fa44f94313d04afe440f58e233347b8fa4c78605.zip
Add \? exit status prompt expansion
Diffstat (limited to 'bin/1sh/parser.c')
-rw-r--r--bin/1sh/parser.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/bin/1sh/parser.c b/bin/1sh/parser.c
index 377ab78f..39b36e67 100644
--- a/bin/1sh/parser.c
+++ b/bin/1sh/parser.c
@@ -2039,6 +2039,16 @@ expandprompt(const char *fmt) {
 				break;
 
 				/*
+				 * Exit status if non-zero.
+				 */
+			case '?':
+				if (exitstatus != 0)
+					snprintf(&ps[i], PROMPTLEN - i, "%d", exitstatus);
+				else
+					i--;
+				break;
+
+				/*
 				 * Superuser status.
 				 *
 				 * '$' for normal users, '#' for root.