From 0171ff50e7e8ce7a8a924868cba58a296664a915 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Wed, 20 Nov 2019 21:46:01 -0500 Subject: Add \? exit status prompt expansion --- bin/1sh/1sh.1 | 9 ++++++--- bin/1sh/parser.c | 10 ++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'bin') 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 @@ -2038,6 +2038,16 @@ expandprompt(const char *fmt) { --i; break; + /* + * Exit status if non-zero. + */ + case '?': + if (exitstatus != 0) + snprintf(&ps[i], PROMPTLEN - i, "%d", exitstatus); + else + i--; + break; + /* * Superuser status. * -- cgit 1.4.1 ;id=71ba7187e5eeeaf2f66bc27bc3b48a2014d37bb7&follow=1'>diff
path: root/ui-snapshot.c (unfollow)
Commit message (Collapse)Author
2018-09-11parsing: ban sprintf()Christian Hesse
Git upstream bans sprintf() with commit: banned.h: mark sprintf() as banned cc8fdaee1eeaf05d8dd55ff11f111b815f673c58 Signed-off-by: Christian Hesse <mail@eworm.de>
2018-09-11parsing: ban strncpy()Christian Hesse
Git upstream bans strncpy() with commit: banned.h: mark strncpy() as banned e488b7aba743d23b830d239dcc33d9ca0745a9ad Signed-off-by: Christian Hesse <mail@eworm.de>
2018-08-28filters: generate anchor links from markdownChristian Hesse
This makes the markdown filter generate anchor links for headings. Signed-off-by: Christian Hesse <mail@eworm.de> Tested-by: jean-christophe manciot <actionmystique@gmail.com>
2018-08-03Bump version.Jason A. Donenfeld
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2018-08-03clone: fix directory traversalJason A. Donenfeld
This was introduced in the initial version of this code, way back when in 2008. $ curl http://127.0.0.1/cgit/repo/objects/?path=../../../../../../../../../etc/passwd root:x:0:0:root:/root:/bin/sh ... Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Reported-by: Jann Horn <jannh@google.com>
2018-08-03config: record repo.snapshot-prefix in the per-repo configKonstantin Ryabitsev