Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: 'set -e' with '!' POSIX issue
On Wed, 5 Oct 2016 14:47:03 +0100
Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> Please reassure me that this is correct:
>
> % ./zsh -fc 'set -e; foo() { false && false; echo OK; }; foo; echo $?'
> OK
> 0
>
> We hit the first "false" in the &&, which doesn't trigger ERR_EXIT so
> the second "false" that would is never executed; therefore we proceed to
> "echo OK"; therefore the status of the function is 0. If there's no
> controversy I may add this as a test case for future reference, together
> with the "true & false" case that causes the function to be aborted.
Here are corresponding tests. Nothing fundamentally new compared with
previous tests, it's just a bit more complicated.
pws
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index 5057dcf..74b83f3 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -596,6 +596,36 @@ F:Must be tested with a top-level script rather than source or function
>before-out
>before-in
+ (setopt err_return
+ fn() {
+ print before-in
+ false && false
+ print after-in
+ }
+ print before-out
+ fn
+ print after-out
+ )
+0:ERR_RETURN not triggered on LHS of "&&" in function
+>before-out
+>before-in
+>after-in
+>after-out
+
+ (setopt err_return
+ fn() {
+ print before-in
+ true && false
+ print after-in
+ }
+ print before-out
+ fn
+ print after-out
+ )
+1:ERR_RETURN triggered on RHS of "&&" in function
+>before-out
+>before-in
+
%clean
rm -f TRAPEXIT
Messages sorted by:
Reverse Date,
Date,
Thread,
Author