zsh-workers
 help / color / mirror / code / Atom feed
* Bug with "return" from inside "if"
@ 2016-11-05 20:25 Bart Schaefer
  2016-11-05 21:00 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2016-11-05 20:25 UTC (permalink / raw)
  To: zsh-workers

% () { if return 1; then echo yes; else echo no; fi } && echo $?
0

This goes back at least as far as zsh 4.2.

diff --git a/Src/loop.c b/Src/loop.c
index b791a89..f65c72b 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -570,7 +570,8 @@ execif(Estate state, int do_exec)
 	cmdpop();
     } else {
 	noerrexit = olderrexit;
-	lastval = 0;
+	if (!retflag)
+	    lastval = 0;
     }
     state->pc = end;
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-11-07  9:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-05 20:25 Bug with "return" from inside "if" Bart Schaefer
2016-11-05 21:00 ` Bart Schaefer
2016-11-05 22:16   ` Bug (?) with "return" from inside "while" Bart Schaefer
2016-11-07  9:38     ` 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).