zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: [PATCH] More ERR_EXIT (was Re: Tests RE behavior of ERR_EXIT)
Date: Wed, 9 Nov 2022 21:22:54 -0800	[thread overview]
Message-ID: <CAH+w=7ZA_TFKfMn6GYwX4HMB8LFUy42kgp+x0iaZE8yLMC0AoQ@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7Z0zT8Lq5BKe4M-JzdjOYhQsmnHJZTVQ7V5+wLBd5u=zA@mail.gmail.com>

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

On Tue, Nov 8, 2022 at 9:29 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> Changed a set of tests from success to xfail.  Anyone have ideas of
> why these aren't working?

Found it.  Grateful for the thorough regression tests in E01options, too.

> Aside, should 'setopt err_return' in the nested function test be using
> localoptions ?

I'm going to vote "yes" ...

[-- Attachment #2: errexit_testspass.txt --]
[-- Type: text/plain, Size: 2687 bytes --]

diff --git a/NEWS b/NEWS
index cdafd1ff5..9c28169bb 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,15 @@ CHANGES FROM PREVIOUS VERSIONS OF ZSH
 
 Note also the list of incompatibilities in the README file.
 
+Changes since 5.9
+-----------------
+
+Handling of ERR_EXIT is corrected when the final status of a structured
+command (for, select, while, repeat, if, case, or a list in braces) is
+nonzero.  To be compatible with other shells, "zsh -e" now exits in
+those circumstances, whereas previous versions did not.  This does not
+affect the handling of nonzero status within conditional statements.
+
 Changes since 5.8.1
 -------------------
 
diff --git a/Src/exec.c b/Src/exec.c
index d4e681887..eef40232e 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1442,6 +1442,8 @@ execlist(Estate state, int dont_change_job, int exiting)
 		    execsimple(state);
 		else
 		    execpline(state, code, ltype, (ltype & Z_END) && exiting);
+		if (unset(ERRRETURN))
+		    this_noerrexit = noerrexit;
 		state->pc = next;
 		goto sublist_done;
 		break;
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index f120809a7..5cc45e2de 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -713,7 +713,7 @@ F:Must be tested with a top-level script rather than source or function
     fi
   }
   fn() {
-    setopt err_return
+    setopt localoptions err_return
     fn2 || true
   }
   fn
@@ -726,8 +726,7 @@ F:Must be tested with a top-level script rather than source or function
   done
   print OK
   )
-0:ERR_EXIT not triggered by status 1 at end of for
->OK
+1:ERR_EXIT triggered by status 1 at end of for
 
   (setopt err_exit
   integer x=0
@@ -736,8 +735,7 @@ F:Must be tested with a top-level script rather than source or function
   done
   print OK
   )
-0:ERR_EXIT not triggered by status 1 at end of while
->OK
+1:ERR_EXIT triggered by status 1 at end of while
 
   (setopt err_exit
   repeat 1; do
@@ -745,8 +743,7 @@ F:Must be tested with a top-level script rather than source or function
   done
   print OK
   )
-0:ERR_EXIT not triggered by status 1 at end of repeat
->OK
+1:ERR_EXIT triggered by status 1 at end of repeat
 
   (setopt err_exit
   if true; then
@@ -754,8 +751,7 @@ F:Must be tested with a top-level script rather than source or function
   fi
   print OK
   )
-0:ERR_EXIT not triggered by status 1 at end of if
->OK
+1:ERR_EXIT triggered by status 1 at end of if
 
   (setopt err_exit
   {
@@ -763,8 +759,7 @@ F:Must be tested with a top-level script rather than source or function
   }
   print OK
   )
-0:ERR_EXIT not triggered by status 1 at end of { }
->OK
+1:ERR_EXIT triggered by status 1 at end of { }
 
   unsetopt err_exit err_return
   (setopt err_exit

  reply	other threads:[~2022-11-10  5:23 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09  5:29 Tests RE behavior of ERR_EXIT Bart Schaefer
2022-11-10  5:22 ` Bart Schaefer [this message]
2022-11-10  5:47   ` [PATCH] More ERR_EXIT (was Re: Tests RE behavior of ERR_EXIT) Bart Schaefer
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:26           ` Philippe Altherr
2022-11-15 19:18             ` 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

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='CAH+w=7ZA_TFKfMn6GYwX4HMB8LFUy42kgp+x0iaZE8yLMC0AoQ@mail.gmail.com' \
    --to=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).