tag 22195 notabug close 22195 stop On 18/12/15 03:22, 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.
Generally you don't want to ignore SIGPIPE. http://pixelbeat/programming/sigpipe_handling.html as then you have to deal with EPIPE from write(): $ trap '' PIPE $ seq 100000 | tee >(head -n1) > >(sed -n '/10000/{p;q}') 1 10000 seq: write error As Bernhard said, the new -p option is a solution to this: $ seq 100000 | tee >(head -n1) > >(tail -n1) 1 14139 $ seq 100000 | tee -p >(head -n1) > >(tail -n1) 1 100000 Note that's an option, rather than the default behavior as POSIX states to handle SIGPIPE in the default manner, and more importantly to support existing cases like the following (yes we don't support both modes of operation): $ yes | tee log | timeout process Since this is somewhat of a subjective default, and this issue pops up so frequently, I've just added it to: http://www.pixelbeat.org/docs/coreutils-gotchas.html#tee cheers, Pádraig