As is documented in the manpage, "$command1 | unbuffer -p $command2" stops processing $command2 as soon as command1 exits. Contrived example:
uname | unbuffer -p sh -c "sleep 1; cat"
The workaround in the manpage amounts to:
(uname; sleep 2) | unbuffer -p sh -c "sleep 1; cat"
However, the above is clunky, and not really reliable: what if the system is unusually busy one day so $command2 takes longer to run than even the modified $command1? Meanwhile, it's a common case for $command2 to be well-behaved -- i.e. grep, or the like. So it would be nice if there were an option that, when $command1 exits, unbuffer feeds an EOF to $command2 and then waits for it.
Log in to post a comment.