zsh-workers
 help / color / mirror / code / Atom feed
From: "Lawrence Velázquez" <larryv@zsh.org>
To: zsh-workers@zsh.org
Subject: Re: errexit and (Z)ERR trap regression
Date: Sat, 22 Jun 2024 01:49:54 -0400	[thread overview]
Message-ID: <33ca21c3-69f8-49f7-9350-2ff9cc4febca@app.fastmail.com> (raw)
In-Reply-To: <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@zsh.org> 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


  reply	other threads:[~2024-06-22  5:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-20 17:12 Martijn Dekker
2024-06-21 18:46 ` Bart Schaefer
2024-06-21 20:02   ` Lawrence Velázquez
2024-06-21 20:36     ` Bart Schaefer
2024-06-22  5:49       ` Lawrence Velázquez [this message]
2024-06-24 23:02         ` Bart Schaefer
2024-06-26 12:42           ` Philippe Altherr
2024-06-26 21:43             ` Bart Schaefer
2024-06-27  2:01               ` Philippe Altherr
2024-06-27 16:43                 ` Bart Schaefer
2024-06-27 17:09                   ` Philippe Altherr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=33ca21c3-69f8-49f7-9350-2ff9cc4febca@app.fastmail.com \
    --to=larryv@zsh.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).