Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: errexit and (Z)ERR trap regression
- X-seq: zsh-workers 52972
- From: Lawrence Velázquez <larryv@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: errexit and (Z)ERR trap regression
- Date: Sat, 22 Jun 2024 01:49:54 -0400
- Archived-at: <https://zsh.org/workers/52972>
- Feedback-id: iaa214773:Fastmail
- In-reply-to: <CAH+w=7ZZsBk6uibaSfLNmvNGf8Uwv1FQ7nZAuPz2xB7zMjh4rQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <5d54375e-8673-45f0-b5ac-f5e0e233d56f@inlv.org> <CAH+w=7YatfKy+vFT1dua5-6cxsgXDaj=GA2qye_nC7fWQ1xUSQ@mail.gmail.com> <2a5f0fa7-23bf-4069-b237-d304965f142e@app.fastmail.com> <CAH+w=7ZZsBk6uibaSfLNmvNGf8Uwv1FQ7nZAuPz2xB7zMjh4rQ@mail.gmail.com>
On Fri, Jun 21, 2024, at 4:36 PM, Bart Schaefer wrote:
> On Fri, Jun 21, 2024 at 1:03 PM Lawrence Velázquez <larryv@xxxxxxx> wrote:
>>
>> The full description of "set -e" in the fresh-out-of-the-oven
>> POSIX.1-2024 is:
>>
>> This requirement applies to the shell environment and each
>> subshell environment separately. For example, in:
>>
>> set -e; (false; echo one) | cat; echo two
>>
>> the `false' command causes the subshell to exit without
>> executing `echo one'
>
> Hm, that doesn't directly address something like
>
> set -e; true && (false; echo one) || echo two
>
> If the subshell should execute "echo one" then the parent should not "echo two".
Right, because early exit is suppressed in the non-final portions
of the AND-OR list and is not reenabled in the subshell. All of
bash, dash, ksh, mksh, yash, and the Solaris 10 Bourne shell print
"one" here.
> Unfortunately I don't follow how any of the POSIX.1-2024 text is meant
> to apply to
>
> set -e; true && { false; echo one; } || echo two
>
> Is "false" there considered to be "any command of an AND-OR list" ?
This ought to work the same as the subshell version: early exit is
suppressed for the commands "true" and "{ false; echo one; }", so
the overall output is still "one". The aforementioned shells behave
this way.
--
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author