Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: kill the LHS command of a pipe once the RHS command terminates
- X-seq: zsh-users 24025
- From: Vincent Lefevre <vincent@xxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: kill the LHS command of a pipe once the RHS command terminates
- Date: Sun, 7 Jul 2019 01:55:37 +0200
- In-reply-to: <CAH+w=7bUROc+9idB-K7ja_mO6BfNAnj0Hq+gUs1678p3FDE9Gg@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mail-followup-to: zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20190628110430.GA13790@zira.vinc17.org> <CAH+w=7bUROc+9idB-K7ja_mO6BfNAnj0Hq+gUs1678p3FDE9Gg@mail.gmail.com>
On 2019-06-29 09:17:13 -0700, Bart Schaefer wrote:
> zsh% coproc { echo foo; sleep 3; echo err >&2 }; head -n 1 <&p; kill %+
> [1] 53747
> foo
> zsh%
> [1] + terminated { echo foo; sleep 3; echo err >&2; }
> zsh%
>
> If you're going to kill the right-side with an interrupt or other
> signal, you'll have to arrange to trap that so that the subsequent
> kill isn't also skipped. Also in practice you want something more
> specific than "kill %+" which could kill the wrong job if you have
> multiple backgrounded jobs and the coproc exits before the kill
> occurs.
Something like that seems to work:
unsetopt NOTIFY
coproc ...
local j="${${$(jobs %+)%%]*}#\[}"
less -f <&p
kill %$j
but I would like to get rid of the job status that appear at the end.
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author