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 Thu, Mar 8, 2012 at 15:53, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> 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)"}")

That will, however, override the value of $status.



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