summary refs log tree commit diff
path: root/bin
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
commit0171ff50e7e8ce7a8a924868cba58a296664a915 (patch)
treedbf5ef32475f281013000204785d10eb52308161 /bin
parentRemove PSlit (diff)
downloadsrc-0171ff50e7e8ce7a8a924868cba58a296664a915.tar.gz
src-0171ff50e7e8ce7a8a924868cba58a296664a915.zip
Add \? exit status prompt expansion
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 7a2d9b57..e1fd98cd 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.
ver-highlight'> 2020-03-09Remove 1sh sourcesJune McEnroe I'm going to recreate it from fresh sh sources for clean git history. 2020-03-08Add The Stone SkyJune McEnroe 2020-03-08Publish "How I Relay Chat"June McEnroe 2020-03-03Don't use $ inside $(())June McEnroe 2020-03-03Remove setoptJune McEnroe 2020-03-03Use getopts in shell scriptsJune McEnroe WTF why did no one tell me about this? 2020-02-27Style %T outside of Rs in italicJune McEnroe 2020-02-26Add Fierce Femmes and Notorious LiarsJune McEnroe 2020-02-23Add This Is How You Lose the Time WarJune McEnroe 2020-02-22Add See Ya LaterJune McEnroe 2020-02-20Remove wiki scriptJune McEnroe Wikipedia seems to have removed the one-sentence extracts from the opensearch results. Too bad. It's not a wiki script, what we need is a command that fetches single-sentence summaries of articles on Wikipedia. 2020-02-19Add The Obelisk GateJune McEnroe 2020-02-17Add Four Tet — HandsJune McEnroe One from the cafe that caught my attention. 2020-02-12Simplify macOS notify-sendJune McEnroe 2020-02-12Add imbox and notemap to pageJune McEnroe 2020-02-12Collapse simple linksJune McEnroe 2020-02-12Move catgirl up the pageJune McEnroe 2020-02-12Update catgirl pty grabJune McEnroe 2020-02-12Link to cgit /about pages where appropriateJune McEnroe 2020-02-11Separate LINKS from BINS for html to workJune McEnroe 2020-02-11Add margin to Bl-bullet itemsJune McEnroe 2020-02-10Match URLs inside parens or with paired parens insideJune McEnroe 2020-02-10Duplicate effective URL before passing it back to curlJune McEnroe Apparently sometimes it didn't like receiving its own internal storage to parse again. Understandable. 2020-02-09Add To Be Taught, If FortunateJune McEnroe 2020-02-04Add The Future of Another TimelineJune McEnroe Wow. One of the best I've read. 2020-01-31Reorganize the Makefile for the umpteenth timeJune McEnroe Broke out LDLIBS for each bin, and made everything more uniform. 2020-01-28Change scout sensitivity to 1.4June McEnroe idk it seems to work. 2020-01-28Import shows.txtJune McEnroe