Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "{ } always { }" construct and return in called functions
- X-seq: zsh-workers 35190
- 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 14:24:51 +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=MYeuoHGWA3e5qfhzrsg1VzjjstbgqT8tR3iZ5ZiKNrI=; b=CRnEVscniDaNoWl4BqazItyT7cSqTHuxKEwoDBELYA/eparGKRH4oMvRZ89oKzIfKd 4wXBBRzGb5kgUFXuFLo5xjy/ibVrepfwvCSt6DggysEiGbEgF18x93CI2WqRhRwIWsf7 e54wRQdHjj/EvZbwfi2EITXLL/t6R9RVIZLMgfjOmw54H555R4Yv+4zuxju0J1ZOCQoQ UEGtGpKv3HILuNQaOfuUHVeDzRK1qliLWpfHZX5JQgFPxqNSrIZFuJPXqO0/TKEGuZRH BBeQTaoqy08JfNJTIxIzD8jgDbLyvfK5M7BkfHuyWmGGdbFpAzldUwPJ/vjOPt/mhY32 TEcQ==
- In-reply-to: <20150518131401.2db3aefa@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> <CAHYJk3RBn_U_ZTNXWHeBfAJyibspcx1=gMM2OTmXz2cpsrrY2Q@mail.gmail.com> <20150518131401.2db3aefa@pwslap01u.europe.root.pri>
On Mon, May 18, 2015 at 2:14 PM, Peter Stephenson
<p.stephenson@xxxxxxxxxxx> wrote:
> 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.
Yes, I have a slightly alternate codepath through my .zshrc triggered
by ZSHRUN being set in the env, used for a Win+r shortcut to run
simple commands in the background. The comment is probably more
accurate for the hook defined below that, used for the normal main
shell case.
> 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.
I would have expected the shell to exit when encountering the "exit"
command, and run no further commands, no matter the circumstances.
Probably a naive viewpoint considering all I've seen. I've reverted
the patch locally for now, but I might investigate more later then.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author