From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29396 invoked by alias); 19 May 2015 06:22:37 -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: 35210 Received: (qmail 12100 invoked from network); 19 May 2015 06:22:35 -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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.0 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=yWfDWhS0CPzlrTbx0oYGwEEVzJuVrxXePzJT3co0FNc=; b=ZWEEfzWjAeE61eUn4mZkqzS/VzHJC67rONXWr7C6pOzFIUCpkzALiCH2A+g/h57JkA RuRSVlPz2zIFsz3yn21nA7hZ8SzarFQIV9J3Wfx2r1rkz4YoArzBo8IhApWG8sNg32Nj sNEzxDNfCfA6ZqfK+a9OGmD1F9YoUH1gGguSCweC+tNZBU3FTBpWbdPCTc6YVrqnXe67 DoUyem7Gh3BKuh586juRh4RxqtCx27zQqwZ31m8Bb3gs/04oQGziRTIzVglmrY+37/WG i8TrRiuqu42pkxsXRYx9ukQld6MmIYePY/q/8VzDWgcl70xpVCyNFFmPA4Yo9CLJ8piz w4Jg== MIME-Version: 1.0 X-Received: by 10.107.163.79 with SMTP id m76mr34455500ioe.85.1432016552584; Mon, 18 May 2015 23:22:32 -0700 (PDT) In-Reply-To: <150518220408.ZM7475@torch.brasslantern.com> References: <20150513155915.71f3daaa@pwslap01u.europe.root.pri> <20150518131401.2db3aefa@pwslap01u.europe.root.pri> <20150518134704.0a7f4293@pwslap01u.europe.root.pri> <150518220408.ZM7475@torch.brasslantern.com> Date: Tue, 19 May 2015 08:22:32 +0200 Message-ID: Subject: Re: "{ } always { }" construct and return in called functions From: Mikael Magnusson To: Bart Schaefer Cc: zsh workers Content-Type: text/plain; charset=UTF-8 On Tue, May 19, 2015 at 7:04 AM, Bart Schaefer wrote: > On May 18, 1:47pm, Peter Stephenson wrote: > } Subject: Re: "{ } always { }" construct and return in called functions > } > } Hmmm... I'm wondering if the fact you've started jobs is important. It > } shouldn't be, with the "&|", and the doshfunc() code is supposed > } to make it irrelevant anyway by setting "stopmsg = 1". > > If you have some other job running in the background, the shell does > not exit when 'exit' is called from a zle widget: > > torch% unsetopt correct > torch% function _accept_and_quit() { > function> local -a buf > function> buf=(${(z)BUFFER}) > function> if which $buf[1] >& /dev/null; then > function then> zsh -c "${BUFFER}" &| > function then> exit > function then> else > function else> zle -M "Command $buf[1] not found" > function else> fi > function> } > torch% zle -N _accept_and_quit > torch% { echo BG: $RANDOM; sleep 30; } & > [1] 7442 > BG: 12801 > torch% bindkey "^M" _accept_and_quit > torch% { echo Here: $RANDOM; sleep 10 } > _accept_and_quit:5: you have running jobs. > torch% { echo Here: $RANDOM; sleep 10 } > torch% Here: 29846 > echo not exited > torch% > zsh: warning: 1 jobs SIGHUPed > > > It's the same effect as this: > > torch% { sleep 30 } & > [1] 7457 > torch% exit > zsh: you have running jobs. > torch% exit > zsh: warning: 1 jobs SIGHUPed > > The difference is that the "you have running jobs" message is suppressed > when exit is called from a zle widget. > > If Mikael adds "unsetopt checkjobs" he should get the effect he wants. > He might also want "setopt nohup" to prevent the death of whatever it > is that's keeping the shell alive. A good theory, but zshrun ~> echo $options[checkjobs] off I've always had that option turned off. Also, since the command is run with &| then surely there are no jobs either way? > The part about "commands are randomly ran two or three times" does not > happen for me -- though I don't know exactly what it means. Does it > mean you can invoke _accept_and_quit two or three times, or does it > mean that running _accept_and_quit once mysteriously launches the same > job two or three times? It seems to be run once in the background by the widget, and then another one in the foreground that I can ctrl-c out of. I only press enter the one time. -- Mikael Magnusson