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 16873
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Is it possible to capture stdout and stderr to separate variables in Zsh?
- Date: Thu, 08 Mar 2012 06:53:32 -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 Mar 7, 10:26am, Nikolai Weibull wrote:
}
} outs=("${(@0):-"$({ out=$(x) } 2>&1; print $'\0'$out$'\0'$status)"}")
That's nice. You can solve the problem that Philippe mentioned with
loss of trailing newlines, by embedding one NUL in $out like so:
outs=("${(@0):-"$({ out="$(x; print -n $'\0')" } 2>&1;
print $'\0'$out$status)"}")
Then I sort of like the idea of making it into an associative array:
typeset -A outs
outs=(STDERR "${(@0):-"$({ out="$(x; print -n $'\0')" } 2>&1;
print $'\0'STDOUT$'\0'${out}STATUS$'\0'$status)"}")
print -r $outs[STDOUT]
Messages sorted by:
Reverse Date,
Date,
Thread,
Author