From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1374 invoked by alias); 10 Sep 2012 06:26:46 -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: 17246 Received: (qmail 9291 invoked from network); 10 Sep 2012 06:26:34 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at linux.vnet.ibm.com does not designate permitted sender hosts) Date: Mon, 10 Sep 2012 14:16:07 +0800 From: Han Pingtian To: zsh-users@zsh.org Subject: Re: Is it possible to capture stdout and stderr to separate variables in Zsh? Message-ID: <20120910061607.GA8015@localhost.localdomain> References: <1331054185.27052.19.camel@air.fifi.org> <120306230111.ZM11639@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12091006-4242-0000-0000-000002D8C766 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.