Subject: bug#11246: Is this a bug in tee?

From: Bob Proulx <[email-masked]>
Date: Sun, 15 Apr 2012 17:00:16 -0600

tags 11246 + notabug
close 11246
thanks

Adrian May wrote:
> ad@pub:~/junk$ echo abcde | tee >(tr a 1) | tr b 2
> a2cde
> 12cde
> 
> I'd have expected 1bcde instead of 12cde. It seems like the tr b 2 is
> acting early on the stream going into tr a 2.

I know you are thinking this somehow is related to 'tee'.  But the
construct you are using ">(...)" is a "Process Substitution" feature
of the bash shell.  I am assuming that you are using bash.  You might
be using another shell.  Look in the bash documentation for process
substitution and you will find all of the documentation for this
feature.  It has nothing to do with 'tee'.  So whether it is happening
early or late the place you really wanted to ask the question was to
the [email-masked] mailing list instead of filing a bug report to
coreutils.

Because of this I am marking the coreutils bug report ticket as
closed.  This does not mean that discussion cannot continue.  Please
feel free to follow up here with more discussion.  Now that the bug
has been created it doesn't hurt any more to have more discussion in
it.  Might as well as far as that goes.

At the root of your problem is that bash implements process
substitution asynchronously.  This is a terrible design misfeature.
It places the write process into the background and does not wait for
it to finish.  This makes the feature almost impossible to be used
without problems.  Because of this design misfeature I never use this
feature.  It isn't suitable for anything except for the most casual of
command line use.

Here is a message where I reported this upstream and was told that I
was the only one who had ever complained about it.  If this is causing
you problems then please submit it as a bug.  Otherwise as it stands I
am the only one complaining about it so far as I know.

  http://lists.gnu.org/archive/html/bug-bash/2007-09/msg00019.html

Also recently on help-bash there was a discussion about this concept
of process substitution.  The thread starts here:

  http://lists.gnu.org/archive/html/help-bash/2012-01/msg00023.html

There was a lot of good discussion about how process substution in
bash works.  I even submitted some diagrams describing the flow of
data through the file descriptors.  I think it was good stuff.  Please
read through that discussion and then let me know here on this bug
report (To: [email-masked]) if that helped with the
understanding or not.

Bob