From: Mikael Magnusson <mikachu@gmail.com>
To: Ronald Fischer <ynnor@mm.st>
Cc: Zsh Mailing-List <zsh-users@zsh.org>
Subject: Re: Possible bug: Zsh function does not terminate when ${name:?word} fails
Date: Wed, 14 Sep 2016 10:19:13 +0200 [thread overview]
Message-ID: <CAHYJk3T+J8bkGmDxMbOBdFiY1EzsvYajG3tKEHRfJV9Bjk9RZw@mail.gmail.com> (raw)
In-Reply-To: <1473840044.77968.725190513.460F8572@webmail.messagingengine.com>
On Wed, Sep 14, 2016 at 10:00 AM, Ronald Fischer <ynnor@mm.st> wrote:
> (See also for a complete discussion:
> http://stackoverflow.com/questions/39463547/zsh-function-does-not-terminate-when-nameword-fails?noredirect=1#comment66276136_39463547)
>
> I have in my .zshrc the following function definition (simplified
> example):
>
> function foo {
> local p=${1:?parameter missing}
> echo continue ....
> }
>
> Running the function by just typing foo produces, as expected, the
> message parameter missing, but it also outputs continue. I had expected
> that the function terminates when the :? check fails, but it continues
> to run.
>
> I tested this with zsh 5.1.1, but I was informed that this behaviour
> also can be reproduced with zsh 5.2
This seems to be a side effect of the reserved word handling, if you do
disable -r local
then it behaves as expected. Being in a function or not makes no
difference, the same thing happens if you do
local p=${foo:?hello}; echo continue
on the command line.
--
Mikael Magnusson
next prev parent reply other threads:[~2016-09-14 9:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20160914080154eucas1p11c49e4dd5f0d45f92deaef1ce08099de@eucas1p1.samsung.com>
2016-09-14 8:00 ` Ronald Fischer
2016-09-14 8:19 ` Mikael Magnusson [this message]
2016-09-14 11:21 ` Ronald Fischer
2016-09-14 16:20 ` Bart Schaefer
2016-09-14 19:08 ` Mikael Magnusson
2016-09-14 9:19 ` 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=CAHYJk3T+J8bkGmDxMbOBdFiY1EzsvYajG3tKEHRfJV9Bjk9RZw@mail.gmail.com \
--to=mikachu@gmail.com \
--cc=ynnor@mm.st \
--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).