Nathan

> I wouldn't be surprised if this has already been addressed, but I was
> browsing the source for tee in shellutils 2.0 and noticed a FIXME
> comment on line 146:
> 
>   /* FIXME: warn if tee is given no file arguments.
>      In that case it's just a slow imitation of `cat.'  */
> 
> So, I think I fixed it.  You will find the diff (generated w/ diff -u3)
> below.  This is the first time I've ever submitted a diff for anything,
> so feel free to let me know if I've done anything wrong (or if my code
> sucks :).

Thanks for your effort to improve the code base.  It is much
appreciated.  However, in this case, I believe the comment to have
been incorrect.  File arguments to the tee command are optional.
There should be no messages generated if no files are specified.  I
will reference the following documentation from the single UNIX
specification.

  http://www.unix-systems.org/single_unix_specification_v2/xcu/tee.html

DESCRIPTION

    The tee utility will copy standard input to standard output,
    making a copy in zero or more files. The tee utility will not buffer
    output.
[...]
OUTPUT FILES

    If any file operands are specified, the standard input will be
    copied to each named file.

It is specifically allowed to not specify files to tee into.  This is
actually useful for things like the following.

  if $logging; then
    logfile="file.log"
  fi
  program | tee $logfile | otherstuff

If logfile is set then tee copies there as it passes data along.  If
not then it evaluates empty and tee only passes data along.  Adding a
warning here would be undesirable and would break traditional usage.
Therefore even though the code is direct to add a warning I believe no
warning should be generated.

Bob

Reply via email to