[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#21919: tee enhancement
From: |
isabella parakiss |
Subject: |
bug#21919: tee enhancement |
Date: |
Mon, 16 Nov 2015 02:22:33 +0100 |
On 11/14/15, Tim Shaw <address@hidden> 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