Re: Pipe behavior clarification?
- Date: Sun, 22 Jan 2017 17:23:47 -0500
- From: Eliot Moss <moss@xxxxxxxxxxxx>
- Subject: Re: Pipe behavior clarification?
On 1/22/2017 3:19 PM, David Balažic wrote:
Is this a correct pipe behavior?
$ echo booo | tee >(md5sum --tag) >/dev/null
MD5 (-) = 9c8b79bdf79ef0ee73a77b8d36d27a2d
$ echo booo | tee >(md5sum --tag) | cat >/dev/null
Here's what I think happens, even if it is a bit counter-intuitive:
>(...) creates a subprocess, whose input comes from some kind
of pipe or socket, and tee is presented with a filename it can
use to write to that socket.
The *output* of the >(...) subprocess is hooked up to what is
known to be the output of tee *at the time the subprocess is
created*. This happens *before* any > redirections are done.
However, in the case of the | pipe, that plumbing is set up
*before* the >(...) construct is acted on.
Note that you could do >(md5sum --tag >whatever) if you want
to specifically control the output of md5sum.
I am sure someone more knowledgeable will correct me if I've
missed anything important here :-) ...
Regards - Eliot Moss
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple