From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6404 invoked by alias); 14 Nov 2015 06:56:35 -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: 20953 Received: (qmail 21193 invoked from network); 14 Nov 2015 06:56:34 -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,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=GRU4p+1Em0H8iG+Wnwirg+AA+lW//8t5vIWRFp8M7ow=; b=lE4mgt42akcx0ZmLRyoFg9QEo4HnaVHaKqs+oGFR1gczTLQBb+y3C7KzS/kHT52GY/ CaMdcMbyDwzpA10mTZ1OZ7ls41yTW1WP+Pt9xIC6+q65fqCl0liJ+dN52VdP6rjO6XMA h9KoedVRQGgxhkjcdamcrcDtgRWAD7AppIterQdZqYyHhCab060W5WS/czCJHxW3EC/V YcM6UzYLC44h0teRvPHI+Hs+GdQZh7Ju8zh2fQ7L4vX0w+Y1Rm1kfDY+nNUnd2CKzBLa cgC04ZE/1Kg3mVuualSd96FNRH/FkUG3+r832t2hBMCFQwYNiL8nw9DHdkEvq+mGOeDH XhSQ== MIME-Version: 1.0 X-Received: by 10.140.102.244 with SMTP id w107mr6628146qge.90.1447484189834; Fri, 13 Nov 2015 22:56:29 -0800 (PST) In-Reply-To: <5646B5F8.3090702@eastlink.ca> References: <5646B5F8.3090702@eastlink.ca> Date: Sat, 14 Nov 2015 07:56:29 +0100 Message-ID: Subject: Re: capturing stderr to variable. From: Mikael Magnusson To: Ray Andrews Cc: Zsh Users Content-Type: text/plain; charset=UTF-8 On Sat, Nov 14, 2015 at 5:18 AM, Ray Andrews wrote: > Gentlemen: > > 'highlight' seems to have no return value. If you feed it a file who's type > it does not recognize, it sends a message to stderr. To create a test for > that, I'm doing this: > > $ highlight $filename 2> /tmp/highlight_err > [ -s "/tmp/highlight_err" ] && > echo="Highlighting is active, but the file is not recognized." > rm /tmp/highlight_err > /dev/null > > ... which is clumsy. Researching it, I find that there's no simple way to > redirect stderr to a variable, or to some other way of capturing the error > condition. Suggestions involve things like: > > ... 2>&4 1>&3; } 2>&1 ) > > ... which I'd not use anyway for clarity's sake. Any suggestions? I was > wondering, since redirection and piping are (I believe) at about the same > level of parsing, one might suppose that " ... 2| " would be legal. That is > to say that we could sent stderr to a command as well as to a file. foo 2> >(bar) -- Mikael Magnusson