Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "{ } always { }" construct and return in called functions
- X-seq: zsh-workers 35186
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: "{ } always { }" construct and return in called functions
- Date: Mon, 18 May 2015 13:38:15 +0200
- Cc: zsh workers <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=NRGk7EptRXA/flxkaqWL1fxK7fKppGzVzP8gOr+ySyY=; b=bAR/lvZVikzRppRZcOm7D/AiDAqHPKI6dcKFwTzPA+Zx8dpxebvf59Sg+094YmYRXA e7SQc4f1PMueYu/Sk68qUPktn05L69i87Y+EK5qjqquyOktnWkeFrfqiDRLswTKyFch3 w3r6JyvsRI8o87LHT6NKTkt87VKY2F8WxumKEvjq7HTM4yNWLB+dwV25lZTB5VjfoOch Ty4p21A45QSrfzQc48NPo7+RJFgsEJoe/d1+r8pvlN4ZRdqq1M99qqWOg+lI3ycqcxUv zRwQ1KJJ8hl5OK/se83MIlAkzBQ/N6h4DKPXEkHsFnUdssisf4Vw1L5q9I8OsTtItTwQ apiw==
- In-reply-to: <20150513155915.71f3daaa@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAHfspHmUOgLjnEMtLBBoeU31Z2GKu8uD5MYE4jsogMKbf+ag9g@mail.gmail.com> <20150513155915.71f3daaa@pwslap01u.europe.root.pri>
On Wed, May 13, 2015 at 4:59 PM, Peter Stephenson
<p.stephenson@xxxxxxxxxxx> wrote:
> On Wed, 13 May 2015 14:31:41 +0200
> ia0 <zsh@xxxxxx> wrote:
>> There is something I don't understand with the "{ } always { }" construct.
>> What is the difference between the two following runs? I would expect the
>> last run to behave as the first one. What am I missing here?
>>
>> *% zsh --version*
>> zsh 5.0.2 (x86_64-pc-linux-gnu)
>> *% cat test*
>> #!/bin/zsh
>>
>> mytrue() { return 0 }
>> mywrap() { echo BEGIN; $1; echo END }
>> mytest() { { exit 1 } always { mywrap $1 } }
>>
>> mytest $1
>> *% ./test true*
>> BEGIN
>> END
>> *1% ./test mytrue*
>> BEGIN
>> *1% *
>
> Nested functions in always blocks with an exit pending are a corner case
> that needs fixing. I'm not sure if this affects exit traps for
> functions, but possibly only in even weirder cases.
>
> Follow-ups can go to zsh-workers --- there are no user-serviceable
> parts inside.
This patch breaks my setup.
# Some hooks into accept-line
if [[ -n "$ZSHRUN" ]]; then
unsetopt correct
function _accept_and_quit() {
local -a buf
buf=(${(z)BUFFER})
if which $buf[1] >& /dev/null; then
zsh -c "${BUFFER}" &|
exit
else
zle -M "Command $buf[1] not found"
fi
}
zle -N _accept_and_quit
bindkey "^M" _accept_and_quit
fi
With the patch, commands are randomly ran two or three times instead
of just once in the background. AFAIK there are no always blocks
involved in this part of my rc.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author