zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: errexit and (Z)ERR trap regression
Date: Fri, 21 Jun 2024 11:46:36 -0700	[thread overview]
Message-ID: <CAH+w=7YatfKy+vFT1dua5-6cxsgXDaj=GA2qye_nC7fWQ1xUSQ@mail.gmail.com> (raw)
In-Reply-To: <5d54375e-8673-45f0-b5ac-f5e0e233d56f@inlv.org>

On Thu, Jun 20, 2024 at 10:12 AM Martijn Dekker <martijn@inlv.org> 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?


  reply	other threads:[~2024-06-21 18:47 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 [this message]
2024-06-21 20:02   ` Lawrence Velázquez
2024-06-21 20:36     ` Bart Schaefer
2024-06-22  5:49       ` Lawrence Velázquez
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='CAH+w=7YatfKy+vFT1dua5-6cxsgXDaj=GA2qye_nC7fWQ1xUSQ@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --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).