zsh-workers
 help / color / mirror / code / Atom feed
From: Philippe Altherr <philippe.altherr@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH] More ERR_EXIT (was Re: Tests RE behavior of ERR_EXIT)
Date: Tue, 15 Nov 2022 08:26:55 +0100	[thread overview]
Message-ID: <CAGdYchuRo81=URPTr7aUzYbL61g6GgV6H7refFXWirWynj5j7w@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7a3W1CdxeKHKC4vEwsW4LUB305f=c1=bzSn5bUYMnX=Ww@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1749 bytes --]

I think that I found the problem. Function calls do save
<https://github.com/zsh-users/zsh/blob/b1533066ca7d50c88b37ce72093c12cf19807818/Src/exec.c#L5765>
and restore
<https://github.com/zsh-users/zsh/blob/b1533066ca7d50c88b37ce72093c12cf19807818/Src/exec.c#L6011>
noerrexit.
They should do the same for this_noerrexit. Furthermore exectry
<https://github.com/zsh-users/zsh/blob/b1533066ca7d50c88b37ce72093c12cf19807818/Src/loop.c#L732>
needs
a "this_noerrexit = 1;" at the very end like all the other "exec" functions
in loop.c. If I do these two changes and revert your two patches, then I
think everything works (my tests and the Zsh tests). I will try to confirm
that after some sleep.

 (
>    setopt ERR_EXIT
>    { { { false && true }
>         } always { print INSIDE: $? } }
>    print OUTSIDE
>  )


> The above should print "INSIDE: 1" (thus not exit) and then exit
> without printing OUTSIDE.


No, I don't think so. "{ ... }" and "{ ... } always { ... }" are both
compound commands that should never trigger an ERR_EXIT on a non-zero exit
status produced by a "false && true" that is coming from the inside (i.e.,
that is bubbling up). If you replace the "{ ... } always { ... }" with an
"if true; then { ... } else { ... }" then you can check with Bash that it
prints "OUTSIDE" (but obviously not "INSIDE").

However, the following should trigger an ERR_EXIT when "foo" returns. With
my changes, it does.

set -e
> function foo() {
>    { { { false && true } } always { print INSIDE: $? } }
> }
> foo
> echo OUTSIDE


Interestingly, this example also works in Zsh 5.8. I guess it's thanks to
the missing "this_noerrexit = 1;" in exectry. The version with an
"if/then/else" instead of the "always" only works with my changes.

Philippe

[-- Attachment #2: Type: text/html, Size: 2734 bytes --]

  parent reply	other threads:[~2022-11-15  7:27 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-12 22:16 Philippe Altherr
2022-11-13  3:59 ` Philippe Altherr
2022-11-13  4:11   ` Bart Schaefer
2022-11-13 13:55     ` Philippe Altherr
2022-11-13 14:24       ` Philippe Altherr
2022-11-13 15:45         ` Philippe Altherr
2022-11-13 16:52           ` Bart Schaefer
2022-11-13 16:45       ` Bart Schaefer
2022-11-13 16:53         ` Bart Schaefer
2022-11-13 18:37           ` Philippe Altherr
2022-11-13 20:55             ` Philippe Altherr
2022-11-13 22:27               ` Bart Schaefer
2022-11-13 23:10               ` Lawrence Velázquez
2022-11-13 22:12             ` Bart Schaefer
2022-11-15  1:11         ` Bart Schaefer
2022-11-15  7:01           ` [PATCH] Even more ERR_EXIT (was Re: More ERR_EXIT " Bart Schaefer
2022-11-15  7:30             ` Philippe Altherr
2022-11-15 19:50               ` Philippe Altherr
2022-11-15  7:26           ` Philippe Altherr [this message]
2022-11-15 19:18             ` [PATCH] More ERR_EXIT (was " Philippe Altherr
2022-11-15 21:08               ` Bart Schaefer
2022-11-16  2:41               ` Lawrence Velázquez
2022-11-16  6:31                 ` Philippe Altherr
2022-11-16  5:51               ` Bart Schaefer
2022-11-16  7:56                 ` Philippe Altherr
2022-11-16 14:21                   ` Philippe Altherr
  -- strict thread matches above, loose matches on Subject: below --
2022-11-09  5:29 Tests RE behavior of ERR_EXIT Bart Schaefer
2022-11-10  5:22 ` [PATCH] More ERR_EXIT (was Re: Tests RE behavior of ERR_EXIT) Bart Schaefer
2022-11-10  5:47   ` Bart Schaefer

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='CAGdYchuRo81=URPTr7aUzYbL61g6GgV6H7refFXWirWynj5j7w@mail.gmail.com' \
    --to=philippe.altherr@gmail.com \
    --cc=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).