summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/1sh/1sh.19
-rw-r--r--bin/1sh/parser.c10
2 files changed, 16 insertions, 3 deletions
diff --git a/bin/1sh/1sh.1 b/bin/1sh/1sh.1
index 65e0bda9..1dbefe09 100644
--- a/bin/1sh/1sh.1
+++ b/bin/1sh/1sh.1
@@ -32,7 +32,7 @@
 .\"	from: @(#)sh.1	8.6 (Berkeley) 5/4/95
 .\" $FreeBSD: releng/12.0/bin/sh/sh.1 336483 2018-07-19 13:09:29Z 0mp $
 .
-.Dd June 24, 2019
+.Dd November 20, 2019
 .Dt 1SH 1
 .Os
 .
@@ -1561,6 +1561,8 @@ This system's hostname.
 The final component of the current working directory.
 .It Li \ew
 The entire path of the current working directory.
+.It Li \e?
+Exit status if it is non-zero, empty string otherwise.
 .It Li \e$
 Superuser status.
 .Dq Li "$ "
@@ -3206,14 +3208,15 @@ has a default value.
 Further prompt customization with
 .Va PS0 ,
 .Va RPS1 ,
-.Va RPS2 ,
-.Va PSlit .
+.Va RPS2 .
 .It
 .Va HOME
 is shortened to
 .Sq ~
 in prompt expansion.
 .It
+Exit status prompt expansion.
+.It
 .Ic fc Fl s Ar = Ns Ar new
 prefixes commands.
 .El
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.