Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: save status in prompt substitution



This saves the status when running substitutions inside prompts.
I can't see how the old code could be right, it would even affect
things like "$(false)%?".

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.33
diff -u -r1.33 options.yo
--- Doc/Zsh/options.yo	25 May 2004 16:51:21 -0000	1.33
+++ Doc/Zsh/options.yo	15 Aug 2004 18:15:06 -0000
@@ -895,7 +895,8 @@
 cindex(prompt, parameter expansion)
 item(tt(PROMPT_SUBST) <K>)(
 If set, em(parameter expansion), em(command substitution) and
-em(arithmetic expansion) are performed in prompts.
+em(arithmetic expansion) are performed in prompts.  Substitutions
+within prompts do not affect the command status.
 )
 pindex(TRANSIENT_RPROMPT)
 item(tt(TRANSIENT_RPROMPT))(
Index: Src/prompt.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/prompt.c,v
retrieving revision 1.21
diff -u -r1.21 prompt.c
--- Src/prompt.c	7 Aug 2004 08:43:58 -0000	1.21
+++ Src/prompt.c	15 Aug 2004 18:15:26 -0000
@@ -163,13 +163,15 @@
 
     if (isset(PROMPTSUBST)) {
 	int olderr = errflag;
+	int oldval = lastval;
 
 	s = dupstring(s);
 	if (!parsestr(s))
 	    singsub(&s);
 
-	/* Ignore errors in prompt substitution */
+	/* Ignore errors and status change in prompt substitution */
 	errflag = olderr;
+	lastval = oldval;
     }
 
     rstring = rs;

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
Work: pws@xxxxxxx
Web: http://www.pwstephenson.fsnet.co.uk



Messages sorted by: Reverse Date, Date, Thread, Author