zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: save status in prompt substitution
@ 2004-08-15 18:20 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2004-08-15 18:20 UTC (permalink / raw)
  To: Zsh hackers list

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@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-08-15 18:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-15 18:20 PATCH: save status in prompt substitution Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).