GNU bug report logs - #11246
Is this a bug in tee?

Previous Next

Package: coreutils;

Reported by: Adrian May <adrian.alexander.may <at> gmail.com>

Date: Sun, 15 Apr 2012 18:11:01 UTC

Severity: normal

Tags: notabug

Done: Bob Proulx <bob <at> proulx.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11246 in the body.
You can then email your comments to 11246 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#11246; Package coreutils. (Sun, 15 Apr 2012 18:11:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Adrian May <adrian.alexander.may <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sun, 15 Apr 2012 18:11:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Adrian May <adrian.alexander.may <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: Is this a bug in tee?
Date: Sun, 15 Apr 2012 19:21:13 +0800
[Message part 1 (text/plain, inline)]
ad <at> 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.

This is a ubuntu server 10.04 machine.

Adrian.
[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#11246; Package coreutils. (Sun, 15 Apr 2012 22:42:01 GMT) Full text and rfc822 format available.

Message #8 received at 11246 <at> debbugs.gnu.org (full text, mbox):

From: "Alan Curry" <pacman-cu <at> kosh.dhis.org>
To: adrian.alexander.may <at> gmail.com (Adrian May)
Cc: 11246 <at> debbugs.gnu.org
Subject: Re: bug#11246: Is this a bug in tee?
Date: Sun, 15 Apr 2012 17:39:47 -0500 (GMT+5)
Adrian May writes:
> 
> ad <at> 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.
> 
> This is a ubuntu server 10.04 machine.
> 
> Adrian.
> 

The shell sets up the pipeline, and your shell is doing it stupidly. With
zsh, you'd get the correct result:

% echo abcde | tee >(tr a 1) | tr b 2
a2cde
1bcde

ksh and bash recently copied the process substitution feature from zsh, and
they haven't got it right yet.

-- 
Alan Curry




Information forwarded to bug-coreutils <at> gnu.org:
bug#11246; Package coreutils. (Sun, 15 Apr 2012 23:02:01 GMT) Full text and rfc822 format available.

Message #11 received at 11246 <at> debbugs.gnu.org (full text, mbox):

From: Bob Proulx <bob <at> proulx.com>
To: Adrian May <adrian.alexander.may <at> gmail.com>
Cc: 11246 <at> debbugs.gnu.org
Subject: Re: bug#11246: Is this a bug in tee?
Date: Sun, 15 Apr 2012 17:00:16 -0600
tags 11246 + notabug
close 11246
thanks

Adrian May wrote:
> ad <at> 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 help-bash <at> gnu.org 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: 11246 <at> debbugs.gnu.org) if that helped with the
understanding or not.

Bob




Added tag(s) notabug. Request was from Bob Proulx <bob <at> proulx.com> to control <at> debbugs.gnu.org. (Sun, 15 Apr 2012 23:02:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 11246 <at> debbugs.gnu.org and Adrian May <adrian.alexander.may <at> gmail.com> Request was from Bob Proulx <bob <at> proulx.com> to control <at> debbugs.gnu.org. (Sun, 15 Apr 2012 23:02:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-coreutils <at> gnu.org:
bug#11246; Package coreutils. (Mon, 16 Apr 2012 08:44:02 GMT) Full text and rfc822 format available.

Message #18 received at 11246 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Bob Proulx <bob <at> proulx.com>
Cc: Adrian May <adrian.alexander.may <at> gmail.com>, 11246 <at> debbugs.gnu.org
Subject: Re: bug#11246: Is this a bug in tee?
Date: Mon, 16 Apr 2012 10:43:41 +0200
Bob Proulx <bob <at> proulx.com> writes:

> At the root of your problem is that bash implements process
> substitution asynchronously.

Why do you think this has anthing to do with asynchronism?  It is
obvious that the stdout of tr a 1 is connected to the pipe, which causes
it to be filtered through tr b 2.  How would a synchronous execution
change anything here?

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 14 May 2012 11:24:02 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 40 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.