Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Even more ERR_EXIT (was Re: More ERR_EXIT Re: Tests RE behavior of ERR_EXIT)



As commented in the other thread, code like the following should NOT trigger an ERR_EXIT (because of exception 3 in the POSIX specification of "set -e").

setopt err_exit
if true; then
  false && true
fi
print OK

The non-zero status of the "if" statement only triggers an ERR_EXIT if it becomes the result of a function call. Then the return of the function triggers the ERR_EXIT, like in the following code:

setopt err_exit
fn() {
  if true; then
    false && true
  fi
}
fn
print OK

The test exit status changes in 50928: fix tests for 50897, mention behavior change in NEWS are incorrect and several tests in the new patch are incorrect.

Philippe


On Tue, Nov 15, 2022 at 8:30 AM Philippe Altherr <philippe.altherr@xxxxxxxxx> wrote:
Oops, I see this only now, just after sending my other reply. I will have a look later. I first need some sleep.

Philippe


On Tue, Nov 15, 2022 at 8:01 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
On Mon, Nov 14, 2022 at 5:11 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> [if workers/50929 makes 50897 redundant then] there's no point in
> bashing through if/case/for/while/repeat/select individually -- the
> only case we have to fix is this one:

I was half right.  Fixing that case revealed that it was necessary to
go through the others, because the "redundant" fix is one level too
far up the stack.

Attached patch removes 50929 again, and amends this_noerrexit from
50897 in each of the complex command exec* functions.  Finally it adds
tests to E01options for each of the cases that Philippe previously
outlined, with the exception of "select" which is interactive.

The tests from 50928 still pass with this patch.  I spent a ridiculous
amount of time with every change I made flopping back and forth
between C03 working and the new E01 failing and vice-versa, before
noticing what happened when I nested a brace _expression_ inside another
one.

Also a minor fix for TRAPDEBUG that caused me some confusion earlier
in the process.

Are there more cases that need testing?


Messages sorted by: Reverse Date, Date, Thread, Author