summaryrefslogtreecommitdiff
path: root/Test
diff options
context:
space:
mode:
authorPhilippe Altherr <philippe.altherr@gmail.com>2024-06-28 21:05:42 -0700
committerBart Schaefer <schaefer@zsh.org>2024-06-28 21:05:42 -0700
commitda733f5df691d01caff0a01addba234aad1b6864 (patch)
treef4490e06d0eaa4300f24ee2ff6851986d73f6941 /Test
parent98a877d32c5ec047c3985183db655cccc707920f (diff)
downloadzsh-da733f5df691d01caff0a01addba234aad1b6864.tar.gz
zsh-da733f5df691d01caff0a01addba234aad1b6864.zip
52977: ERR_EXIT/ERR_RETURN are respected by the final command in && / || lists
Diffstat (limited to 'Test')
-rw-r--r--Test/C03traps.ztst27
1 files changed, 27 insertions, 0 deletions
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index de57765a0..87b7fd1f7 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -995,6 +995,33 @@ F:Must be tested with a top-level script rather than source or function
?loop 0
?loop 1
+ ( set -e; true && {false; echo NOT REACHED} )
+ ( trap "print Trapped!" ERR; true && {false} )
+ ( trap "print Trapped!" ERR; true && if true; then false; fi )
+ ( trap "print Trapped!" ERR; true && {false} always {true} )
+ ( true && (set -e; false; echo NOT REACHED) )
+ ( true && (trap "print Trapped!" ERR; false) )
+ ( true && { set -e; false; echo NOT REACHED } )
+ ( true && { trap "print Trapped!" ERR; false } )
+ ( set -e; true && (false; echo one) || echo two )
+ ( set -e; true && { false; echo one; } || echo two )
+0:ERR_EXIT is triggered by last command in an AND-OR list
+>Trapped!
+>Trapped!
+>Trapped!
+>Trapped!
+>Trapped!
+>one
+>one
+
+ ( set -o ERR_RETURN; f() { false; echo NOT REACHED; }; f || true; echo OK )
+ ( set -o ERR_RETURN; f() { true && false; echo NOT REACHED; }; f || true; echo OK )
+ ( set -o ERR_RETURN; f() { true && { false }; echo NOT REACHED; }; f || true; echo OK )
+0:ERR_RETURN is triggered in function calls on the left of an AND-OR
+>OK
+>OK
+>OK
+
if zmodload zsh/system 2>/dev/null; then
(
trap 'echo TERM; exit 2' TERM