From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25796 invoked by alias); 14 Nov 2015 17:20:56 -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: 20955 Received: (qmail 2299 invoked from network); 14 Nov 2015 17:20:53 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Authority-Analysis: v=2.1 cv=X+5rdgje c=1 sm=1 tr=0 a=2HRJbREI7CNh35z1D4ZSNQ==:117 a=2HRJbREI7CNh35z1D4ZSNQ==:17 a=N659UExz7-8A:10 a=3F-pKQ1QkFYlTt74eaMA:9 a=pILNOxqGKmIA:10 Message-id: <56476D72.6010006@eastlink.ca> Date: Sat, 14 Nov 2015 09:20:50 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: capturing stderr to variable. References: <5646B5F8.3090702@eastlink.ca> <151114000101.ZM611@torch.brasslantern.com> In-reply-to: <151114000101.ZM611@torch.brasslantern.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit On 11/14/2015 12:01 AM, Bart Schaefer wrote: > The shell language doesn't define a digit preceding a "|" symbol as a > redirection because "|" separates commands whereas ">" modifies the > single current command. The difference makes more sense if you are > aware that redirections can appear anywhere: Thanks, lucid as always. Yeah, the two things might be parsed at the same level, but they are not symmetrical with each other. > { highlight ... >/dev/tty } 2>&1 | read highlight_err > # now $highlight_err has the first line of stderr > # (this does not work in most shells other than zsh) > > Note that without the braces, 2>&1 combines stdout and stderr so > both go to /dev/tty and "read" either has no input or reads from > the terminal (depending on whether the "multios" option is set). > Well that sure beats some of the solutions I found on the net. The only think obscure there is why redirecting stdout to where it's going anyway does anything. Speaking of obscurites, have you given any thought to that cloning of the environment thing I mentioned a while back? Of course it's impossible for the same variable to exist several times in the environment, nevertheless 'set' was reporting exactly that, it seems. It sounds significant. Then seeing what's going on: $ set | grep "aArchive" A=/aArchive A=/aArchive A=/aArchive A=/aArchive A=/aArchive ... that's impossible, however ...