zsh-users
 help / color / mirror / code / Atom feed
From: Daniel Santana da Silva <daniel@santana.tech>
To: zsh-users@zsh.org
Subject: Unexpected err_return behavior inside if/else block
Date: Sun, 8 Jul 2018 20:17:05 -0300	[thread overview]
Message-ID: <CALLDFesbpqq4b0YGAQsHo-45pYqpL84kZFkw5TYpnKrG6SdaEQ@mail.gmail.com> (raw)

The following script outputs "status: 1", where I'd expect the script
to exit right after the called function failed with the `false`
statement:

    #!/usr/bin/env zsh

    setopt err_return
    function { if :; then false; fi }
    echo status: $?

But if the function is replaced in the following way, the last line
is never reached (as I expected):

    #!/usr/bin/env zsh

    setopt err_return
    function { true && false }
    echo status: $?

It seems that the "err_return" option is not respected by the caller
when the called function is exited from inside an if/else block (and
other blocks too e.g. `repeat 1 { false }` or `for i in 1; { false }`).

Is this the intended behavior, or is it a bug?


             reply	other threads:[~2018-07-08 23:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180708231827epcas2p40dbb906c426d30ebb2a700a25f54a8b7@epcas2p4.samsung.com>
2018-07-08 23:17 ` Daniel Santana da Silva [this message]
2018-07-09  9:45   ` Peter Stephenson

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=CALLDFesbpqq4b0YGAQsHo-45pYqpL84kZFkw5TYpnKrG6SdaEQ@mail.gmail.com \
    --to=daniel@santana.tech \
    --cc=zsh-users@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).