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.
> 
> # 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.

Are you actually trying to exit from the main shell here?  It claims to
be a hook into accept-line but it doesn't look to me like it is.

The key here is presumably sorting out what functions are running at
what level, i.e. where the "exit" command is first run and where the
shell actually exits (you could trying adding a message after "exit" to
see if that gets run, though that probably won't help since "retflag" is
likely to be set at that point).  In particular, what should happen is
the code at the end of doshfunc() causes the shell to exit at the end of
_accept_and_quit.  The simpler the case, the more likely
the relationship is to come out.

pws



Messages sorted by: Reverse Date, Date, Thread, Author