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(-) 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 e='1'/>
path: root/port (unfollow)
Commit message (Collapse)Author
2020-06-16Fix doas checkJune McEnroe
2020-06-16Add LC_COLLATE=C to ls aliasJune McEnroe
2020-06-11Fix pbd for neovimJune McEnroe
At some point neovim started setting argv[0] to the absolute path for some reason.
2020-06-11Alias sudo=doas if availableJune McEnroe
2020-06-11Add all VMs to ssh configJune McEnroe
2020-06-08Add additional permission for linking with LibreSSLJune McEnroe
https://www.gnu.org/licenses/gpl-faq.en.html#GPLIncompatibleLibs
2020-06-08Replace __DECONST with regular castsJune McEnroe
sed -E 's/__DECONST[(]([^,]+), ([^)]+)[)]/(\1)(\2)/'
2020-06-08Replace __printflike with __attribute__((format(printf, ...)))June McEnroe
sed -E 's/__printf0?like[(]([^,]+), ([^)]+)[)]/__attribute__((format(printf, \1, \2)))/'
2020-06-08Replace __dead2 with __attribute__((noreturn))June McEnroe
sed 's/__dead2/__attribute__((noreturn))/'
2020-06-08Replace __FBSDID macros with commentsJune McEnroe
sed -E 's|__FBSDID[(]"([^"]+)"[)];|/* \1 */|'
2020-06-08Remove reference to FreeBSD-specific libedit hackJune McEnroe
Newer versions of libedit have sane tab-complete now without FreeBSD's hacks, and in fact the hack is gone in FreeBSD-CURRENT. I'm still a little confused why binding this weird function is necessary at all, but at least it exists everywhere, I guess.
2020-06-08Prefix mandoc with exec in about-filterJune McEnroe
2020-06-07Remove mktemp options from mkbuiltins, mktokensJune McEnroe
Why even?
2020-06-07Cast z_stream fields to size_tJune McEnroe
In the version of zlib in OpenBSD, these fields are of type off_t, which is signed (why?), rather than uLong.
2020-06-07Call static_assert by _Static_assertJune McEnroe
OpenBSD doesn't #define static_assert in assert.h and _Static_assert is its real name I guess so why not?
2020-06-07Add OpenBSD to install.shJune McEnroe
Straightforward.
2020-06-03Add The Song of AchillesJune McEnroe
2020-06-01Allow redirecting input in everJune McEnroe
2020-05-31Add %c conversion to c scriptJune McEnroe
2020-05-31Add c script to READMEJune McEnroe
2020-05-31Add c scriptJune McEnroe
2020-05-31Update mdoc source URLsJune McEnroe
2020-05-26Remove unfinished PSF fontsJune McEnroe