Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Possible bug: Zsh function does not terminate when ${name:?word} fails
- X-seq: zsh-users 21904
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Ronald Fischer <ynnor@xxxxx>
- Subject: Re: Possible bug: Zsh function does not terminate when ${name:?word} fails
- Date: Wed, 14 Sep 2016 10:19:13 +0200
- Cc: Zsh Mailing-List <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=/QlfER1WSUHd/Zjlc8MAi2UU9QgT+kamCdYjLLgSL0s=; b=CAzJJOYo1girfCS8i9W+nvUeV5rfiG6hTHimrFblMqxZOv7QySAQUSeUUAbA8dUcgx rinAfwuM4HPJiY4kZA43SFe57EK3qbtExOl0kbDL62CmrxdfUjMF75/RFAlFGFkX0jj5 oBEKwo8m2gz7QCp2UvslYl1IuN3O1Vfm1Qo0FM8KeK/iLJ2Wxsp+LIb6IWw3axvJOkvD bdnY7lhS0PriE9GEeBJSmbH4klbl6PRIgNqXvlI4kLqFCUDKoBeMsqyYlQXo1BK16JKt OhIEppijwF/mItRXh7ldRGuPck7MPPcX+Ucm8Tu3DUTlTupKTn/L1KuSRf/mFzNu9B2O g2jQ==
- In-reply-to: <1473840044.77968.725190513.460F8572@webmail.messagingengine.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <1473840044.77968.725190513.460F8572@webmail.messagingengine.com>
On Wed, Sep 14, 2016 at 10:00 AM, Ronald Fischer <ynnor@xxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author