From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Radon Rosborough <radon.neon@gmail.com>, zsh-workers@zsh.org
Subject: Re: Question about err_return
Date: Wed, 23 Aug 2017 17:56:08 +0100 [thread overview]
Message-ID: <20170823175608.4e89cca4@ntlworld.com> (raw)
In-Reply-To: <CADB4rJG_ajfBdeC+Cd4YHDhi2pXRr3j7tCXKrV_AvT6+Y7_U7A@mail.gmail.com>
On Sun, 20 Aug 2017 22:28:34 -0700
Radon Rosborough <radon.neon@gmail.com> wrote:
> Hi all,
>
> I have a question about err_return. Specifically, why does the
> following:
>
> function { setopt err_return; false; echo 'oh no' }
>
> print nothing, while
>
> function { setopt err_return; false; echo 'oh no' } && true
>
> prints 'oh no'? This seems very inconsistent to me, as I would expect
> the result of 'x && true' to be the same as 'x' in all circumstances.
It's probably just a bug that we don't reset the state inside functions.
We did have tests assuming it worked this way, but it's not documented
and not obvious, so I think it makes sense to change it.
I can do this, but I need to be careful about one subtlety: whether
ERR_EXIT is still suppressed in that case. I think the answer is yes
--- it applies globally rather than hierarchically. To go with bash, it
would mean (so far as I can see) this applies even if err_exit is
explicitly set in the function --- i.e. suppression of the effect really
is controlled by internal and not user-visible state.
In that case I'll have to do a bit more work separating out the innards
of the two options.
pws
next prev parent reply other threads:[~2017-08-23 17:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-21 5:28 Radon Rosborough
2017-08-21 6:27 ` Daniel Shahaf
2017-08-23 16:56 ` Peter Stephenson [this message]
2017-08-23 20:09 ` Peter Stephenson
2017-08-24 10:33 ` 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=20170823175608.4e89cca4@ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=radon.neon@gmail.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).