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)
- X-seq: zsh-workers 50976
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Philippe Altherr <philippe.altherr@xxxxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: [PATCH] More ERR_EXIT (was Re: Tests RE behavior of ERR_EXIT)
- Date: Tue, 15 Nov 2022 21:51:54 -0800
- Archived-at: <https://zsh.org/workers/50976>
- In-reply-to: <CAGdYchucse2HcYKHsA6Y9DrQ-21yTV=xLpvfJE=VWHbAX7C_nA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAGdYchsPpEMNwWFtukBS1ZzWob_hZOm8Mnnmp9Uey2T4pWs63g@mail.gmail.com> <CAGdYchu66aYu+3yzYGtMnNcT6GcWziWe9YWNqOv5_T=JpCynRg@mail.gmail.com> <CAH+w=7YD3jXE5Yy+J-dQVNVeJagHPH6HeFsavKjzAPJyaGDGWA@mail.gmail.com> <CAGdYchvTBX8o5PZgZwDy6C6TRqyFrd+M7A-dXJHP3t1zAuRHdQ@mail.gmail.com> <CAH+w=7YpsK2T6q1=-PAKkgyHov68U5YcdryLGhvBjrSYcYk7tQ@mail.gmail.com> <CAH+w=7a3W1CdxeKHKC4vEwsW4LUB305f=c1=bzSn5bUYMnX=Ww@mail.gmail.com> <CAGdYchuRo81=URPTr7aUzYbL61g6GgV6H7refFXWirWynj5j7w@mail.gmail.com> <CAGdYchucse2HcYKHsA6Y9DrQ-21yTV=xLpvfJE=VWHbAX7C_nA@mail.gmail.com>
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