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

Bug with "return" from inside "if"



% () { 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;
 



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