Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
errexit and (Z)ERR trap regression
- X-seq: zsh-workers 52967
- From: Martijn Dekker <martijn@xxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: errexit and (Z)ERR trap regression
- Date: Thu, 20 Jun 2024 18:12:43 +0100
- Archived-at: <https://zsh.org/workers/52967>
- List-id: <zsh-workers.zsh.org>
Two manifestations of the same bug in the current dev version:
$ zsh -e -c 'true && false; echo NOT REACHED' # no output; correct
$ zsh -c 'true && (set -e; false; echo NOT REACHED)' # incorrect output
NOT REACHED
and
$ zsh -c 'trap "echo Trapped!" ERR; true && false' # correct output
Trapped!
$ zsh -c 'true && (trap "print Trapped!" ERR; false)' # no output; bug
The -e option and the (Z)ERR trap should be disabled for the left hand side of
&&/|| but not for the right hand side (or, as POSIX puts it, set -e should be
disabled for "any command of an AND-OR list other than the last"). zsh 5.8.x
works correctly.
A 'git bisect' revealed that this bug was introduced in:
commit 259f1e944b96715fda25f7ba227da05bdb7e600f
Author: Philippe Altherr <philippe.altherr@xxxxxxxxx>
Date: Sat Dec 3 21:03:36 2022 -0800
51071: fix ERR_RETURN for functions in conditional statements
--
|| modernish -- harness the shell
|| https://github.com/modernish/modernish
||
|| KornShell lives!
|| https://github.com/ksh93/ksh
Messages sorted by:
Reverse Date,
Date,
Thread,
Author