Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Piping stderr (was Re: Two bug reports)

On Sat, 23 Mar 2002, Bart Schaefer wrote:
> On Mar 23,  1:18pm, Wayne Davison wrote:
> } I'm wondering if it would be nice to create a syntax for piping just
> } stderr?
> You mean, other than `2>>(...)'?

Uh ...  Yeah, Yeah.  That's what I meant.  _Other_ than that.  :-)

(I had apparently neglected to find that syntax when I was searching
the zsh man page.)

So, I suppose that Peter's reply to David Hughes could be ammended to
say that in addition to turning off multios, he could change this

    /bin/sh -c 'echo out; echo err >&2' 2>&1 >/dev/null | cat

into this one:

    /bin/sh -c 'echo out; echo err >&2' >/dev/null 2>>(cat)

The bad thing about this idiom is that it doesn't wait for "cat" to
finish before moving on.  If we implemented my proposed stderr-pipe
syntax, the following command wouldn't have that problem:

    /bin/sh -c 'echo out; echo err >&2' >/dev/null 2>|& cat

> Hmm.  `|&' is short for `2>&1 |'.  What would the new syntax be short
> for?

It wouldn't be short for anything.  Instead "|" would become short for
"1>|&".  The construct simply means "take the numbered file handle and
pipe it to stdin of the following command."

> The problem being that in order to pipe "just stderr" you have
> to dispose of stdout somehow.

No, stdout doesn't need to be affected at all.  If the user wants stdout
to go somewhere other than the default, it can be redirected explicitly
(as I did above).


Messages sorted by: Reverse Date, Date, Thread, Author