tee appears to drop its input (i.e. it does not write it into the specified
log file) if stdout is closed.

I didn't expect this behaviour, and POSIX
   http://www.opengroup.org/susv3/utilities/tee.html
does not mandate this behaviour either. Rather, it says:
  "If any file operands are specified, the standard input shall be copied to
   each named file."

$ tee --version
tee (GNU coreutils) 6.12.70-4f470

$ rm -f empty; touch empty; rm -f output output2; \
  for a in 0 1 2 3 4 5 6 7 8 9 ; do \
    for b in 0 1 2 3 4 5 6 7 8 9 ; do \
      echo g$a$b | tee -a output; \
      echo h$a$b >> output2; \
    done; \
    sleep 2; \
  done \
  | { sleep 1; join --nocheck-order -v 2 - empty; }

The 'join' command notices that its second argument is empty, stops reading,
and exits immediately.
As a result, while a is 1 2 3 4 5 6 7 8 9, stdout is already closed.
The file 'output2' contains 100 lines, which shows that all loop iterations
were performed. The file 'output' contains only 10 lines, showing that 'tee'
dropped the output for a > 0.

Bruno



_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to