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?
- X-seq: zsh-users 17215
- From: Paul Maisano <pemstir@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Is it possible to capture stdout and stderr to separate variables in Zsh?
- Date: Fri, 31 Aug 2012 00:40:15 +0000 (UTC)
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CADdV=Mtbszh2NjtB8yFjfeo9PR1U7XV-Qi2AQMXCZ0Ag0VTS+w@mail.gmail.com>
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