diff options
author | June McEnroe <june@causal.agency> | 2020-03-09 19:15:33 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-03-09 20:01:30 -0400 |
commit | d495c77ca7d302a4c4c39ac42eedd9288ce007bb (patch) | |
tree | 1e6af6672e4a6bc2d96bc63d2f32d186dce50217 | |
parent | Add RPS1 and RPS2 right prompts (diff) | |
download | src-d495c77ca7d302a4c4c39ac42eedd9288ce007bb.tar.gz src-d495c77ca7d302a4c4c39ac42eedd9288ce007bb.zip |
Add PS0 pre-prompt string
Diffstat (limited to '')
-rw-r--r-- | bin/1sh/1sh.1 | 6 | ||||
-rw-r--r-- | bin/1sh/parser.c | 6 | ||||
-rw-r--r-- | bin/1sh/var.c | 3 | ||||
-rw-r--r-- | bin/1sh/var.h | 2 |
4 files changed, 17 insertions, 0 deletions
diff --git a/bin/1sh/1sh.1 b/bin/1sh/1sh.1 index 5ce17a5f..9bbd881b 100644 --- a/bin/1sh/1sh.1 +++ b/bin/1sh/1sh.1 @@ -1404,6 +1404,12 @@ unless this variable is in the environment. A later change of parent process ID is not reflected. A subshell retains the same value of .Va PPID . +.It Va PS0 +The pre-prompt string, +which is printed before each new prompt. +.Va PS0 +may include any of the formatting sequences from +.Va PS1 . .It Va PS1 The primary prompt string, which defaults to .Dq Li "$ " , diff --git a/bin/1sh/parser.c b/bin/1sh/parser.c index b92b9462..080b84e7 100644 --- a/bin/1sh/parser.c +++ b/bin/1sh/parser.c @@ -129,6 +129,7 @@ static void consumetoken(int); static void synexpect(int) __dead2; static void synerror(const char *) __dead2; static void setprompt(int); +static char *expandprompt(const char *); static int pgetc_linecont(void); @@ -1937,6 +1938,11 @@ setprompt(int which) if (which == 0) return; + if (which == 1 && *ps0val()) { + out2str(expandprompt(ps0val())); + flushout(out2); + } + #ifndef NO_HISTORY if (!el) #endif diff --git a/bin/1sh/var.c b/bin/1sh/var.c index f82da2e6..b501ef4a 100644 --- a/bin/1sh/var.c +++ b/bin/1sh/var.c @@ -92,6 +92,7 @@ struct var vifs; struct var vmail; struct var vmpath; struct var vpath; +struct var vps0; struct var vps1; struct var vps2; struct var vps4; @@ -116,6 +117,8 @@ static const struct varinit varinit[] = { NULL }, { &vpath, 0, "PATH=" _PATH_DEFPATH, changepath }, + { &vps0, VUNSET, "PS0=", + NULL }, /* * vps1 depends on uid */ diff --git a/bin/1sh/var.h b/bin/1sh/var.h index cdec2ee0..1bdf4afd 100644 --- a/bin/1sh/var.h +++ b/bin/1sh/var.h @@ -77,6 +77,7 @@ extern struct var vifs; extern struct var vmail; extern struct var vmpath; extern struct var vpath; +extern struct var vps0; extern struct var vps1; extern struct var vps2; extern struct var vps4; @@ -103,6 +104,7 @@ extern int initial_localeisutf8; #define mailval() (vmail.text + 5) #define mpathval() (vmpath.text + 9) #define pathval() (vpath.text + 5) +#define ps0val() (vps0.text + 4) #define ps1val() (vps1.text + 4) #define ps2val() (vps2.text + 4) #define ps4val() (vps4.text + 4) |