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

ERR__EXIT failure (was Re: zsh 5.2-test-1)



And plus also free bonus with same fix on { ... } --- see tests.  But it
occurs to me perhaps it's not that simple...

What about ( ... )?  We can't check what's going on inside, so
presumably exiting on any non-zero status from that must be right?

If so, is it really right to suppress exit on the status at the end of {
... } or should the two work the same way?  I think the difference is
intrinsic, so this fix is correct, but I'll wait for opinions.

pws

diff --git a/Src/exec.c b/Src/exec.c
index 6e197dd..a439aec 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -429,6 +429,7 @@ execcursh(Estate state, int do_exec)
     cmdpop();
 
     state->pc = end;
+    this_noerrexit = 1;
 
     return lastval;
 }
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index e94fb6f..dc386a4 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -664,6 +664,15 @@ F:Must be tested with a top-level script rather than source or function
 >OK
 
   (setopt err_exit
+  {
+    false && true
+  }
+  print OK
+  )
+0:ERR_EXIT not triggered by status 1 at end of { }
+>OK
+
+  (setopt err_exit
   for x in y; do
     false
   done
@@ -696,6 +705,14 @@ F:Must be tested with a top-level script rather than source or function
   )
 1:ERR_EXIT triggered by status 1 within if
 
+  (setopt err_exit
+  {
+    false
+  }
+  print OK
+  )
+1:ERR_EXIT triggered by status 1 within { }
+
   if zmodload zsh/system 2>/dev/null; then
   (
     trap 'echo TERM; exit 2' TERM



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