zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: 'set -e' with '!' POSIX issue
Date: Thu, 06 Oct 2016 09:36:11 +0100	[thread overview]
Message-ID: <20161006093611.4cef772f@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20161005144703.12fdf6c4@pwslap01u.europe.root.pri>

On Wed, 5 Oct 2016 14:47:03 +0100
Peter Stephenson <p.stephenson@samsung.com> 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


  reply	other threads:[~2016-10-06  8:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-02 10:01 Martijn Dekker
2016-10-02 17:55 ` Peter Stephenson
2016-10-04  7:45   ` Vincent Lefevre
2016-10-04  8:30     ` Peter Stephenson
2016-10-05 10:18       ` Martijn Dekker
2016-10-05 11:37         ` Peter Stephenson
2016-10-05 13:47         ` Peter Stephenson
2016-10-06  8:36           ` Peter Stephenson [this message]
2016-10-06 11:22           ` Martijn Dekker

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=20161006093611.4cef772f@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.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).