From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17881 invoked by alias); 22 May 2015 22:31:18 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35266 Received: (qmail 5716 invoked from network); 22 May 2015 22:31:16 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 X-Originating-IP: [80.3.228.158] X-Spam: 0 X-Authority: v=2.1 cv=RLtOZNW+ c=1 sm=1 tr=0 a=P+FLVI8RzFchTbbqTxIDRw==:117 a=P+FLVI8RzFchTbbqTxIDRw==:17 a=kj9zAlcOel0A:10 a=NLZqzBF-AAAA:8 a=pGLkceISAAAA:8 a=yJK6W8x_wl0M5QTIQFAA:9 a=CjuIK1q_8ugA:10 Date: Fri, 22 May 2015 23:31:13 +0100 From: Peter Stephenson To: zsh workers Subject: Re: "{ } always { }" construct and return in called functions Message-ID: <20150522233113.76b13026@ntlworld.com> In-Reply-To: References: <20150513155915.71f3daaa@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 18 May 2015 13:38:15 +0200 Mikael Magnusson 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;