Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "{ } always { }" construct and return in called functions
- X-seq: zsh-workers 35266
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: "{ } always { }" construct and return in called functions
- Date: Fri, 22 May 2015 23:31:13 +0100
- In-reply-to: <CAHYJk3RBn_U_ZTNXWHeBfAJyibspcx1=gMM2OTmXz2cpsrrY2Q@mail.gmail.com>
- 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> <CAHYJk3RBn_U_ZTNXWHeBfAJyibspcx1=gMM2OTmXz2cpsrrY2Q@mail.gmail.com>
On Mon, 18 May 2015 13:38:15 +0200
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> This patch breaks my setup.
>
> 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.
The story appears to be someone decided there should be a double
start/end parameter scope for reasons I'm scrupulously going to avoid
investigating (it's not new), so the locallevel jumps. So the new test
never triggers. Adding a ">" puts this back how it was.
This is the last thing I have to look at; is anyone else expecting
something to happen?
pws
diff --git a/Src/exec.c b/Src/exec.c
index 527dffb..527d611 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5109,7 +5109,7 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
* when we have an "always" block. The endparamscope() has
* already happened, hence the "+1" here.
*/
- if (exit_pending && exit_level == locallevel+1) {
+ if (exit_pending && exit_level >= locallevel+1) {
if (locallevel > forklevel) {
/* Still functions to return: force them to do so. */
retflag = 1;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author