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

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



On Tue, Nov 15, 2022 at 11:19 AM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> Here is a patch with which all tests pass (the Zsh ones, including the new ones that the patch adds, and my tests mentioned in this thread).

Thanks.  Please don't name attached files with suffix ".patch",
".diff", ".zsh", etc., as some mail readers won't display them and
they won't be inlined by the zsh-workers list archive server.  Just
use ".txt" unless there is something in the attachment that would be
damaged if interpreted that way (hopefully that won't ever be true of
a patch).

> +++ b/Test/C03traps.ztst
> @@ -713,29 +713,48 @@ F:Must be tested with a top-level script rather than source or function
>      fi
>    }
>    fn() {
> -    setopt localoptions err_return
> +    setopt err_return
>      fn2 || true
>    }
> -  fn
> +  (fn)

Did using localoptions here break something?

Aside from that, I'd like to look at how we got here.  Way back in
workers/50873 (https://www.zsh.org/mla/workers/2022/msg01203.html) you
posted an attachment "bug.zsh" and wrote:

> The output of the script (with Zsh 5.8 on Linux and Zsh 5.8.1 on macOS) is the following:
>
>> aaa: 0
>> bbb: 1
>> ccc: 1
>
> The documentation of ERR_EXIT mentions the special case of conditional expressions. I understand that the command "false" by itself in the expression "false && true" shouldn't trigger an exit since it appears in a position where a condition is expected. However, since the expression "false && true" as a whole evaluates to a non-zero status and doesn't appear in a position where a condition is expected, I would assume that it should trigger an exit. Thus, in my opinion the script should have the following output:
>
>> aaa: 0
>
> That's obviously not the case.

I started making all my changes on the premise that "bbb: 1" was
incorrect output.  After fix-err-exit.patch is applied, the bug.zsh
script outputs

aaa: 0
bbb: 1

So my question is, was the whole premise of the thread that started
there, incorrect?  Because we come to workers/50897 (which
fix-err-exit.patch reverses) where I made this comment:

> There is the question of why ignoring a false status at the end of a
> complex command has so far been considered correct for ERR_EXIT,
> according to C03.  This is a disagreement with e.g. bash.

Your current assertion is that those tests were correct all along,
because you've reverted them back to the 5.8.1/5.9 status, so ...
they're not a disagreement with bash?

Somewhere along the line we pivoted from "errexit isn't exiting in
case X" to "errexit shouldn't exit in case Y" and (given also
Lawrence's remarks RE source and eval) I'm not sure we've yet resolved
that any of the approaches to Y are satisfactory for X.

> I have no clue how you obtain the change numbers (like 50929 and 50928)

Those are zsh-workers article numbers from the X-Seq header in each
message in the archives.




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