1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-09-28 15:01:21 +02:00

45373: Fix ERR_EXIT bug in else branch of if.

The flags need resetting for this branch otherwise e.g. command
substitution with non-zero status doesn't cause exit.
This commit is contained in:
Peter Stephenson 2020-02-02 18:05:47 +00:00
parent 7a9467e430
commit e01223a26c
3 changed files with 15 additions and 1 deletions

@ -1,3 +1,8 @@
2020-02-02 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 45373: Src/loop.c, Test/C03traps.ztst: ERR_EXIT failed on
command substitution in else branch.
2020-02-02 Daniel Shahaf <danielsh@apache.org>
* 45372: Etc/BUGS: Record a symlink loop bug involving :P

@ -570,7 +570,7 @@ execif(Estate state, int do_exec)
if (run) {
/* we need to ignore lastval until we reach execcmd() */
if (olderrexit)
if (olderrexit || run == 2)
noerrexit = olderrexit;
else if (lastval)
noerrexit |= NOERREXIT_EXIT | NOERREXIT_RETURN | NOERREXIT_UNTIL_EXEC;

@ -500,6 +500,15 @@
>Succeed 2
>Succeed 3
(set -e
if false; then
else
a=$(false)
print This should not appear
fi
)
1:ERREXIT is triggered in an else block after a cmd subst returning false
fn() {
emulate -L zsh
setopt errreturn