From 9a17762b0cdf0112f54a86e7937118422ba65614 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sat, 31 Jul 2010 19:36:53 +0000 Subject: users/15217: use top-level status when redrawing prompt --- Src/Zle/zle_main.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'Src') diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 16f98186f..5c6b65db3 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -83,6 +83,14 @@ int done; /**/ int mark; +/* + * Status ($?) saved before function entry. This is the + * status we need to use in prompts. + */ + +/**/ +static int pre_zle_status; + /* * Last character pressed. * @@ -1129,6 +1137,12 @@ zleread(char **lp, char **rp, int flags, int context) free(pptbuf); return shingetline(); } + /* + * The current status is what we need if we are going + * to display a prompt. We'll remember it here for + * use further in. + */ + pre_zle_status = lastval; keytimeout = (time_t)getiparam("KEYTIMEOUT"); if (!shout) { @@ -1756,6 +1770,14 @@ reexpandprompt(void) static int reexpanding; if (!reexpanding++) { + /* + * If we're displaying a status in the prompt, it + * needs to be the toplevel one, not the one from + * any status set within the local zle function. + */ + int local_lastval = lastval; + lastval = pre_zle_status; + free(lpromptbuf); lpromptbuf = promptexpand(raw_lp ? *raw_lp : NULL, 1, NULL, NULL, &pmpt_attr); @@ -1763,6 +1785,7 @@ reexpandprompt(void) free(rpromptbuf); rpromptbuf = promptexpand(raw_rp ? *raw_rp : NULL, 1, NULL, NULL, &rpmpt_attr); + lastval = local_lastval; } reexpanding--; } -- cgit 1.4.1