Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Yet another errexit bug?
- X-seq: zsh-workers 53098
- From: Lawrence Velázquez <larryv@xxxxxxx>
- To: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: Yet another errexit bug?
- Date: Fri, 20 Sep 2024 17:15:54 -0400
- Archived-at: <https://zsh.org/workers/53098>
- Feedback-id: iaa214773:Fastmail
- In-reply-to: <CAH+w=7aeBpQa4fh2nGrp=qAp0JxkZXEmsibV=Px8oBRHQ5QByw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAH+w=7aeBpQa4fh2nGrp=qAp0JxkZXEmsibV=Px8oBRHQ5QByw@mail.gmail.com>
On Fri, Sep 20, 2024, at 2:05 PM, Bart Schaefer wrote:
> I thought we'd squashed all of these, but:
>
> % ! ( setopt errexit; false; print notreached )
> notreached
> % print $?
> 1
>
> Compare bash:
>
> $ ! ( set -e; false; echo notreached; )
> $ echo $?
> 0
>
> Zsh still leaking "noerrexit" into subshells, I guess?
>
> Curiously however, bash (5.0.17):
>
> $ ( set -e; false; echo notreached; ) && echo here
> notreached
> here
>
> So bash is treating a subshell in AND/OR as different than subshell
> preceded by NOT? Zsh matches bash in the AND case, so maybe zsh's NOT
> behavior is actually more consistent?
From a quick reread, it seems to me that zsh is satisfying the "!"
requirement of POSIX "set", while bash isn't:
The -e setting shall be ignored when executing the compound
list following the "while", "until", "if", or "elif" reserved
word, a pipeline beginning with the "!" reserved word, or
any command of an AND-OR list other than the last.
And these shells agree with zsh:
- dash 0.5.12
- ksh93u+ 2012-08-01
- mksh R59 2020/10/31
- OpenBSD 7.5 pdksh
- yash 2.56.1
% cat /tmp/foo.sh
! (set -e; false; echo notreached)
echo "$?"
% bash /tmp/foo.sh
0
% bash --posix /tmp/foo.sh
0
% dash /tmp/foo.sh
notreached
1
% ksh /tmp/foo.sh
notreached
1
% mksh /tmp/foo.sh
notreached
1
% oksh /tmp/foo.sh
notreached
1
% yash /tmp/foo.sh
notreached
1
% zsh /tmp/foo.sh
notreached
1
--
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author