Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: capturing stderr to variable.
- X-seq: zsh-users 20953
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Subject: Re: capturing stderr to variable.
- Date: Sat, 14 Nov 2015 07:56:29 +0100
- Cc: Zsh Users <zsh-users@xxxxxxx>
- 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==
- In-reply-to: <5646B5F8.3090702@eastlink.ca>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <5646B5F8.3090702@eastlink.ca>
On Sat, Nov 14, 2015 at 5:18 AM, Ray Andrews <rayandrews@xxxxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author