I think I’ve figured out how to tweak your experience
to turn it into something other people will be able to reproduce:
$ (echo hello; sleep 1; echo world) | tee >(cat)
hello
hello … and, after a brief delay,
world
world
$ echo "$?"
0
$ (echo hello; sleep 1; echo world) | tee >(echo yo)
yo
hello
$ echo "$?"
141
As you hopefully understand,
>(command) creates a pipe
to a process running command.
The standard input of command is connected to a pathname
that other commands on the command line (in this case, tee)
can open and write to. When command is cat,
the process sits there and reads from stdin until it gets an EOF.
In this case, tee has no problem
writing all the data it reads from its stdin to the pipe.
But, when command is echo yo,
the process writes yo to the stdout and immediately exits.
This causes a problem for tee;
when it writes to a pipe with no process at the other end,
it gets a SIGPIPE signal.
Apparently OS X’s version of tee
writes to the file(s) on the command line first, and then its stdout.
So, in your example (echo hi | tee >(echo yo)),
tee gets the pipe failure on its very first write.
Whereas, the version of tee on Linux and Cygwin
writes to the stdout first,
so it manages to write hi to the screen before it dies.
In my enhanced example, tee dies when it writes hello to the pipe,
so it doesn’t get a chance to read and write world.
echodoes not print its stdin. it prints its args from the cmd line. which doesn't explain why thehiisn't being printed or why you're getting a pipefail error code. – cas Apr 04 '16 at 05:10bash4.3.42(0)-release, I get no output (neitherhi, noryo) exceptMissing name for redirect.. Exit code is1rather than114. – cas Apr 04 '16 at 05:28echo hi | strace -fe write tee >(echo yo)and paste the output – cuonglm Apr 05 '16 at 01:56