Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: "{ } always { }" construct and return in called functions



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