[net.wanted.sources] Mods to tee...

geoff@desint.UUCP (Geoff Kuenning) (01/17/85)

(The original article was in net.sources)

In article <350@rna.UUCP> dan@rna.UUCP (Dan Ts'o) writes:

>Hi,
>	Recent I had reason to dig up an old mod I made to /bin/tee. Basically
>the mods allow tee to accept shell pipeline commands as descriptors to
>copy stdin to in addition to regular files. That is,
>
>	$ tee file1 "|prog1 | prog2" file2
>
>is possible, where the second argument is a shell pipeline which receives a
>copy of stdin as well as a file1 and file2. This property is useful when, for
>example, you want to view the data as its passing down the pipeline. I'm
>forever doing something like,
>
>	$ prog1 | tee /dev/tty | prog2
>
>to view the pipeline data. Now it is also possible to do,
>
>	$ prog1 | tee "|more" | prog2
>
...
>	Below are the diffs for 4.2BSD's tee...

Last summer I posted a Sharchive that will do this in a more general fashion,
and for any program.  The archive contained:

	mytee.c    Replacement for tee(1) that handles piping
	copen.c	   Replacement for open(2) and close(2) that handles piping
	fcopen.c   Replacement for fopen(2) and fclose(2) that handles piping

The subroutines can be used to directly replace open(2) and fopen(3) calls;
no other changes are needed unless your program responds to blanks in
(so-called) filenames.

However, my notation is a little bit different.  I was (and am) hoping to get
the folks at Berkeley and at USG to pick up the routines and add calls to them
in one or two strategic places (like in tee(1)).  The notation I chose is
amenable to this, because it allows the shells to be modified so that you don't
require quoting.  In specific, I would use:

	$ prog | tee "(sort -u | more)" | prog2

currently, which could become:

	$ prog | tee (sort -u | more) | prog2

when the shells had been modified.

What do people think of these two notations?  I have to confess I think Dan's
is more mnemonic and consistent with other software, but mine has the
advantage that it can be more cleanly integrated with the shells.

If people are interested, I'll repost my versions too.
-- 

	Geoff Kuenning
	...!ihnp4!trwrb!desint!geoff