Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Is it possible to capture stdout and stderr to separate variables in Zsh?
On Tue, Mar 06, 2012 at 11:01:11PM -0800, Bart Schaefer wrote:
> On Mar 6, 9:16am, Philippe Troin wrote:
> }
> } On Tue, 2012-03-06 at 09:09 +0100, Nikolai Weibull wrote:
> } > Is it possible to capture stdout and stderr to separate variables in Zsh?
> }
> } All I can think of is:
> }
> } coproc cat &
> } pid=$!
> } stdout="$( ( print "printed on stdout"; print -u 2 "printer on stderr" ) 2>&p )"
> } sleep 1
> } kill "$pid"
> } stderr="$(cat <&p)"
> }
> } You'll notice the very ugly sleep+kill hack I had to use as I could not
> } find how you can close a coprocess's standard input cleanly. Removing
> } the sleep+kill makes the cat <&p hang forever.
>
> You need this: http://www.zsh.org/mla/users/2011/msg00095.html :-)
>
Hi,
I'm using zsh 5.0, but looks like still cannot close the prior coproc
with "coproc exit":
% coproc while read line;do print -r -- "$line:u";done
[1] 31518
% coproc exit
[2] 31519
%
[2] + done exit
% jobs
[1] + running while read line; do; print -r -- "$line:u"; done
%
or I'm missing something here?
Thanks.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author