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 17246
- From: Han Pingtian <hanpt@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Is it possible to capture stdout and stderr to separate variables in Zsh?
- Date: Mon, 10 Sep 2012 14:16:07 +0800
- In-reply-to: <CADdV=MthDr4RZhO1pUni9qW5S2j1H_xu7iQOBTAs=vP84Gei8Q@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>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CADdV=Mtbszh2NjtB8yFjfeo9PR1U7XV-Qi2AQMXCZ0Ag0VTS+w@mail.gmail.com> <1331054185.27052.19.camel@air.fifi.org> <120306230111.ZM11639@torch.brasslantern.com> <CADdV=MthDr4RZhO1pUni9qW5S2j1H_xu7iQOBTAs=vP84Gei8Q@mail.gmail.com>
On Wed, Mar 07, 2012 at 10:26:57AM +0100, Nikolai Weibull wrote:
> Invoking two additional commands (mktemp and rm) is prohibitively
> expensive on Cygwin for my use case. I used the following solution
> instead:
>
> outs=("${(@0):-"$({ out=$(x) } 2>&1; print $'\0'$out$'\0'$status)"}")
Looks like it can be written as:
outs=("${(0)$({ out=$(x) } 2>&1; print $'\0'$out$'\0'$status)}")
e.g.
% outs=("${(0)$({ out=$(fuser /usr/local/bin/zsh) } 2>&1; print $'\0'$out$'\0'$status)}")
/usr/local/bin/zsh: ee
8013 14594
0
So the $'\n' and $'\0' are both reserved in the nested command
substitution since the whole substitution is in double quote. Not sure
if this is right here.
Thanks.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author