From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 593 invoked by alias); 30 Mar 2012 14:49:29 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16937 Received: (qmail 5152 invoked from network); 30 Mar 2012 14:49:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <120330074900.ZM14469@torch.brasslantern.com> Date: Fri, 30 Mar 2012 07:49:00 -0700 In-reply-to: Comments: In reply to Nikolai Weibull "Re: Is it possible to capture stdout and stderr to separate variables in Zsh?" (Mar 30, 9:15am) References: <1331054185.27052.19.camel@air.fifi.org> <120306230111.ZM11639@torch.brasslantern.com> <120308065332.ZM14313@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh Users Subject: Re: Is it possible to capture stdout and stderr to separate variables in Zsh? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Mar 30, 9:15am, Nikolai Weibull wrote: } Subject: Re: Is it possible to capture stdout and stderr to separate varia } } On Thu, Mar 8, 2012 at 15:53, Bart Schaefer 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. Indeed, good catch. You need to pull $status inside the $(...) too (in which case the trailing newline doesn't matter any more): outs=("${(@0):-"$({ out="$(x; print $'\0'$status)" } 2>&1; print $'\0'$out)"}")