Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: errexit and (Z)ERR trap regression
- X-seq: zsh-workers 52976
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Philippe Altherr <philippe.altherr@xxxxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: errexit and (Z)ERR trap regression
- Date: Wed, 26 Jun 2024 14:43:32 -0700
- Archived-at: <https://zsh.org/workers/52976>
- In-reply-to: <CAGdYchvP9x83UtFH855_ddE1m88cMJdNmk27+RwzHC9KSJ=ucA@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> <33ca21c3-69f8-49f7-9350-2ff9cc4febca@app.fastmail.com> <CAH+w=7YrF3RMjqY6RJKjH=o8pTziok08aAx4g8gfff9_KYdVuQ@mail.gmail.com> <CAGdYchvP9x83UtFH855_ddE1m88cMJdNmk27+RwzHC9KSJ=ucA@mail.gmail.com>
On Wed, Jun 26, 2024 at 5:43 AM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> I think that the correct fix is the following:
>
> if (isandor || isnot)
> noerrexit = oldnoerrexit | NOERREXIT_EXIT | NOERREXIT_RETURN;
> else
> noerrexit = oldnoerrexit;
This doesn't seem necessary to me. For one thing, it's equivalent to:
noerrexit = oldnoerrexit;
if (isandor || isnot)
noerrexit |= NOERREXIT_EXIT | NOERREXIT_RETURN;
But assigning (noerrexit = oldnoerrexit) presumes that noerrexit was
(improperly?) cleared at or after the point where olderrexit was
recorded. If that were the situation, then --
> For reminder, here is the current code:
>
> if (isandor || isnot)
> noerrexit |= NOERREXIT_EXIT | NOERREXIT_RETURN;
-- would be insufficient for the existing test cases, I think. That
is, either (olderrexit == noerrexit), or it's not necessary to
OR-together olderrexit with the new values.
> Here are two other examples fixed by this patch:
>
> zsh -c 'trap "echo Trapped!" ERR; true && if true; then false; fi'
> zsh -c 'trap "echo Trapped!" ERR; true && {false} always {true}'
These two cases also pass with my patch from workers/52973. Do you
have an example where my patch doesn't work?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author