GNU bug report logs - #21919
tee enhancement

Previous Next

Package: coreutils;

Reported by: "Tim Shaw" <timshaw <at> mail.usa.com>

Date: Sat, 14 Nov 2015 16:09:01 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.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 21919 in the body.
You can then email your comments to 21919 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#21919; Package coreutils. (Sat, 14 Nov 2015 16:09:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Tim Shaw" <timshaw <at> mail.usa.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sat, 14 Nov 2015 16:09:02 GMT) Full text and rfc822 format available.

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

From: "Tim Shaw" <timshaw <at> mail.usa.com>
To: bug-coreutils <at> gnu.org
Subject: tee enhancement
Date: Sat, 14 Nov 2015 17:00:30 +0100
[Message part 1 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#21919; Package coreutils. (Mon, 16 Nov 2015 00:01:02 GMT) Full text and rfc822 format available.

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

From: Pádraig Brady <P <at> draigBrady.com>
To: Tim Shaw <timshaw <at> mail.usa.com>, 21919 <at> debbugs.gnu.org
Subject: Re: bug#21919: tee enhancement
Date: Sun, 15 Nov 2015 23:59:55 +0000
On 14/11/15 16:00, Tim Shaw wrote:
> If I am using stdout redirection of a shell block to capture some text I am generating, errors need to go to stderr, but it would also be good if they went into the generated output. For example
> for i in files*; do
>   if there_is_an_error; then
>     echo big long complicated error message goes here >&2
>     echo big long complicated error message goes here
>     continue
>   fi
>    stuff_producing_text_on_stdout
> done > file_i_am_creating
>  
> I do not like duplicating code, such as the big long error message echo. So, I could create a temp file or a temp shell var to save the message, but that makes things more complicated than just duplicating the code, and also is just not my style for something transient like this.
>  
> What I would like to do is add a parameter to tee, "-2", that copies to stderr in addition to stdout, just like "-" copies to stdout twice. 

Note `tee -` now copies to a file called '-' rather than
duplicating to stdout, since v8.24 as discussed at:
http://lists.gnu.org/archive/html/coreutils/2015-02/msg00085.html

> So the code becomes
>     echo big long complicated error message goes here | tee -2
> Simple, eh?
>  
> Where's the tee source? I know this would not be POSIX compliant, but it would work for me, and I hate having to rewrite everything from scratch for trivial stuff like this.

Maybe shell constructs like this would suffice?

  { echo error | tee >(cat >&2); }

cheers,
Pádraig.




Information forwarded to bug-coreutils <at> gnu.org:
bug#21919; Package coreutils. (Mon, 16 Nov 2015 00:24:02 GMT) Full text and rfc822 format available.

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

From: Pádraig Brady <P <at> draigBrady.com>
To: Tim Shaw <timshaw <at> mail.usa.com>, 21919 <at> debbugs.gnu.org
Subject: Re: bug#21919: tee enhancement
Date: Mon, 16 Nov 2015 00:23:38 +0000
tag 21919 notabug
close 21919
stop

On 15/11/15 23:59, Pádraig Brady wrote:
> On 14/11/15 16:00, Tim Shaw wrote:
>> If I am using stdout redirection of a shell block to capture some text I am generating, errors need to go to stderr, but it would also be good if they went into the generated output. For example
>> for i in files*; do
>>   if there_is_an_error; then
>>     echo big long complicated error message goes here >&2
>>     echo big long complicated error message goes here
>>     continue
>>   fi
>>    stuff_producing_text_on_stdout
>> done > file_i_am_creating
>>  
>> I do not like duplicating code, such as the big long error message echo. So, I could create a temp file or a temp shell var to save the message, but that makes things more complicated than just duplicating the code, and also is just not my style for something transient like this.
>>  
>> What I would like to do is add a parameter to tee, "-2", that copies to stderr in addition to stdout, just like "-" copies to stdout twice. 
> 
> Note `tee -` now copies to a file called '-' rather than
> duplicating to stdout, since v8.24 as discussed at:
> http://lists.gnu.org/archive/html/coreutils/2015-02/msg00085.html
> 
>> So the code becomes
>>     echo big long complicated error message goes here | tee -2
>> Simple, eh?
>>  
>> Where's the tee source?

tee source is at http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/tee.c

> I know this would not be POSIX compliant, but it would work for me, and I hate having to rewrite everything from scratch for trivial stuff like this.
> 
> Maybe shell constructs like this would suffice?
> 
>   { echo error | tee >(cat >&2); }

Or this is simpler:

  echo error | tee /dev/stderr

cheers,
Pádraig.




Information forwarded to bug-coreutils <at> gnu.org:
bug#21919; Package coreutils. (Mon, 16 Nov 2015 01:29:02 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Tim Shaw <timshaw <at> mail.usa.com>, 21919 <at> debbugs.gnu.org
Subject: Re: bug#21919: tee enhancement
Date: Sun, 15 Nov 2015 17:28:08 -0800
Tim Shaw wrote:
>       echo big long complicated error message goes here | tee -2

How about "tee /dev/stderr" instead of a new option?  "tee /dev/stderr"  already 
works on many platforms now.  We could easily arrange for it to work on the 
remaining platforms where it does not already work.




Information forwarded to bug-coreutils <at> gnu.org:
bug#21919; Package coreutils. (Mon, 16 Nov 2015 01:42:02 GMT) Full text and rfc822 format available.

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

From: isabella parakiss <izaberina <at> gmail.com>
To: Tim Shaw <timshaw <at> mail.usa.com>
Cc: 21919 <at> debbugs.gnu.org
Subject: Re: bug#21919: tee enhancement
Date: Mon, 16 Nov 2015 02:22:33 +0100
On 11/14/15, Tim Shaw <timshaw <at> mail.usa.com> wrote:
> If I am using stdout redirection of a shell block to capture some text I am
> generating, errors need to go to stderr, but it would also be good if they
> went into the generated output. For example
> for i in files*; do
>   if there_is_an_error; then
>     echo big long complicated error message goes here >&2
>     echo big long complicated error message goes here
>     continue
>   fi
>    stuff_producing_text_on_stdout
> done > file_i_am_creating
>
> I do not like duplicating code, such as the big long error message echo. So,
> I could create a temp file or a temp shell var to save the message, but that
> makes things more complicated than just duplicating the code, and also is
> just not my style for something transient like this.
>
> What I would like to do is add a parameter to tee, "-2", that copies to
> stderr in addition to stdout, just like "-" copies to stdout twice. So the
> code becomes
>     echo big long complicated error message goes here | tee -2
> Simple, eh?
>
> Where's the tee source? I know this would not be POSIX compliant, but it
> would work for me, and I hate having to rewrite everything from scratch for
> trivial stuff like this.

tee /dev/stderr

---
xoxo iza




Information forwarded to bug-coreutils <at> gnu.org:
bug#21919; Package coreutils. (Mon, 16 Nov 2015 07:07:02 GMT) Full text and rfc822 format available.

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

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Tim Shaw <timshaw <at> mail.usa.com>, 21919 <at> debbugs.gnu.org
Subject: Re: bug#21919: tee enhancement
Date: Mon, 16 Nov 2015 08:06:18 +0100
On 11/14/2015 05:00 PM, Tim Shaw wrote:
> What I would like to do is add a parameter to tee, "-2", that copies to stderr in addition to stdout, just like "-"
> copies to stdout twice. So the code becomes
>     echo big long complicated error message goes here | tee -2
> Simple, eh?

Having an additional option to refer to a certain file descriptor
sounds worthwhile and tempting.  OTOH, you can already refer to
/dev/stderr as a file name for the 2nd file descriptor already
on many/most systems:

  echo big long complicated error message goes here | tee /dev/stderr

Does this work for you?

> Where's the tee source? I know this would not be POSIX compliant, but it would work for me, and I hate having to rewrite
> everything from scratch for trivial stuff like this.

http://git.savannah.gnu.org/cgit/coreutils.git/tree/README-hacking

Have a nice day,
Berny




Added tag(s) notabug. Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 24 Oct 2018 21:20:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 21919 <at> debbugs.gnu.org and "Tim Shaw" <timshaw <at> mail.usa.com> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 24 Oct 2018 21:20:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 22 Nov 2018 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 269 days ago.

Previous Next


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