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?



Nikolai Weibull <now <at> bitwi.se> writes:

> 
> Hi!
> 
> Is it possible to capture stdout and stderr to separate variables in Zsh?
> 
> I understand that it’s not possible in sh, but I was wondering if any
> of Zsh’s additions in the redirection area would allow for such a
> separation.

Try this:

var1=`cmd` 2>&1 | read var2

Now var1 contains stdout from cmd and var2 contains stderr!

It might work with other shells too.

Regards,

Paul Maisano





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