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

Re: errexit and (Z)ERR trap regression



On Thu, Jun 20, 2024 at 10:12 AM Martijn Dekker <martijn@xxxxxxxx> wrote:
>
>      $ zsh -c 'true && (set -e; false; echo NOT REACHED)'  # incorrect output
>      $ zsh -c 'true && (trap "print Trapped!" ERR; false)'  # no output; bug

These two examples can be fixed by resetting the "noerrs"-related
flags on entry to the subshell, although I'm not sure that's correct
when the subshell appears earlier in the chain.  Of course even then,
exit from the subshell won't be treated as anything other than part of
the boolean condition in the parent.

However, given this --

> disabled for "any command of an AND-OR list other than the last"

-- the question is whether the behavior should be the same when using
brace commands instead of subshells:

% zsh -c 'true && { set -e; false; echo NOT REACHED }'
% zsh -c 'true && { trap "print Trapped!" ERR; false }'

Certainly we don't want to reset the flag even on the last command
when (for example) the AND-OR list appears in the condition part of an
"if" or similar construct.

Is my recollection incorrect, that there's a change related to this in
the as-yet-unpublished next revision of POSIX?




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