From 1ca02130e9838cdd223abad9e147c8178055683f Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Thu, 10 Jan 2019 21:07:26 -0500 Subject: Set RPROMPT from RPS1 and RPS2 --- bin/cash/parser.c | 84 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 26 deletions(-) (limited to 'bin/cash/parser.c') diff --git a/bin/cash/parser.c b/bin/cash/parser.c index 5a7c7876..86c09776 100644 --- a/bin/cash/parser.c +++ b/bin/cash/parser.c @@ -1969,35 +1969,11 @@ pgetc_linecont(void) return (c); } -/* - * called by editline -- any expansions to the prompt - * should be added here. - */ -char * -getprompt(void *unused __unused) -{ +static char * +expandprompt(const char *fmt) { static char ps[PROMPTLEN]; - const char *fmt; const char *pwd; int i, trim; - static char internal_error[] = "??"; - - /* - * Select prompt format. - */ - switch (whichprompt) { - case 0: - fmt = ""; - break; - case 1: - fmt = ps1val(); - break; - case 2: - fmt = ps2val(); - break; - default: - return internal_error; - } /* * Format prompt string. @@ -2077,6 +2053,62 @@ getprompt(void *unused __unused) return (ps); } +/* + * called by editline -- any expansions to the prompt + * should be added here. + */ +char * +getprompt(void *unused __unused) +{ + const char *fmt; + static char internal_error[] = "??"; + + /* + * Select prompt format. + */ + switch (whichprompt) { + case 0: + fmt = ""; + break; + case 1: + fmt = ps1val(); + break; + case 2: + fmt = ps2val(); + break; + default: + return internal_error; + } + + return expandprompt(fmt); +} + +char * +getrprompt(void *unused __unused) +{ + const char *fmt; + static char internal_error[] = "??"; + + /* + * Select prompt format. + */ + switch (whichprompt) { + case 0: + fmt = ""; + break; + case 1: + fmt = rps1val(); + break; + case 2: + fmt = rps2val(); + break; + default: + return internal_error; + } + + return expandprompt(fmt); +} + const char * expandstr(const char *ps) -- cgit 1.4.1