Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
capturing stderr to variable.
- X-seq: zsh-users 20952
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: capturing stderr to variable.
- Date: Fri, 13 Nov 2015 20:18:00 -0800
- 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
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author