GNU bug report logs -
#22195
deviation from POSIX in tee
Previous Next
Reported by: Eric Renouf <erenouf <at> skaion.com>
Date: Thu, 17 Dec 2015 20:35:01 UTC
Severity: normal
Tags: notabug
Done: Assaf Gordon <assafgordon <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 12/18/2015 04:22 AM, Paul Eggert wrote:
> Eric Renouf wrote:
>> If a write to any successfully opened file operand fails
>
> But the write didn't fail here. Instead, a signal was sent to 'tee'. If you
> don't want the signal, trap it. E.g.:
>
> trap '' PIPE
> for i in {1..300}; do
> echo "$i"
> echo "$i" >&2
> sleep 1
> done | tee >(head -1 > h.txt; echo "Head done") \
> >(tail -1 > t.txt) >/dev/null
>
> will give the behavior you want.
>
> So there is no deviation from POSIX here.
Furthermore, tee got the new --output-error=MODE option in
version 8.24 to have more control over this:
$ src/tee --help
...
-p diagnose errors writing to non pipes
--output-error[=MODE] set behavior on write error. See MODE below
...
MODE determines behavior with write errors on the outputs:
'warn' diagnose errors writing to any output
'warn-nopipe' diagnose errors writing to any output not a pipe
'exit' exit on error writing to any output
'exit-nopipe' exit on error writing to any output not a pipe
The default MODE for the -p option is 'warn-nopipe'.
The default operation when --output-error is not specified, is to
exit immediately on error writing to a pipe, and diagnose errors
writing to non pipe outputs.
A minor note to your command: instead of redirecting tee's output to
/dev/null, you could use another pipe to save the write operations
in tee to it:
producer \
| tee --output-error=warn \
>(head -1 > h.txt; echo "Head done") \
| tail -1 > t.txt
Have a nice day,
Berny
This bug report was last modified 6 years and 263 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.