[comp.binaries.ibm.pc.d] Filters

ggw@wolves.uucp (Gregory G. Woodbury) (03/03/90)

In article <103509@looking.on.ca> brad@looking.on.ca (Brad Templeton) writes:
>The concept of
>	type foo | tiny-dabe >abe.arc
>is silly.  It is not meant to be a filter in this manner.  You would use
>	tiny-dabe <foo >abe.arc

	Uhm, Brad.  These two forms are equivalent.
	There is a difference in that the computer doesn't have to do the
"type" explicitly, but the effect is the same.  The "<" symbol means that
the file named is connected to the "standard input" of the program and the
">" symbol says that the "standard output" of the program is to be redirected
to the named file.  The definition of a "filter" is that it accepts its input
on the "standard input" and produces its output on the "standard output".
	This, being the heart of the concept of toolmaking in programming,
allows a program to be more general and allows the user to combine the program
with others in a way that is not necessesarily forseen by the author of the
program.
-- 
Gregory G. Woodbury
Sysop/owner Wolves Den UNIX BBS, Durham NC
UUCP: ...dukcds!wolves!ggw   ...dukeac!wolves!ggw           [use the maps!]
Domain: ggw@cds.duke.edu  ggw@ac.duke.edu  ggw%wolves@ac.duke.edu
Phone: +1 919 493 1998 (Home)  +1 919 684 6126 (Work)
[The line eater is a boojum snark! ]           <standard disclaimers apply>

ggdavis@tiger.waterloo.edu (Greg Davis) (03/04/90)

In article <1990Mar3.042312.12638@wolves.uucp> ggw@wolves.UUCP (Gregory G. Woodbury) writes:
>In article <103509@looking.on.ca> brad@looking.on.ca (Brad Templeton) writes:
>>	type foo | tiny-dabe >abe.arc
>>	tiny-dabe <foo >abe.arc
>
>	Uhm, Brad.  These two forms are equivalent.

No they're not.  DOS uses temporary files for pipes.  All the output of
"type foo" will go to a file and this file will be input for "dabe".
Using a pipe is needlessly doing an extra operation and creating an
extra file.  Using redirection is definitely more efficient than using
a pipe.

roy@comcon.UUCP (Roy M. Silvernail) (03/04/90)

In article <1990Mar3.042312.12638@wolves.uucp>, ggw@wolves.uucp (Gregory G. Woodbury) writes:
> In article <103509@looking.on.ca> brad@looking.on.ca (Brad Templeton) writes:
> >The concept of
> >	type foo | tiny-dabe >abe.arc
> >is silly.  It is not meant to be a filter in this manner.  You would use
> >	tiny-dabe <foo >abe.arc
> 
> 	Uhm, Brad.  These two forms are equivalent.

Gregory, the original comment came from me. UUnfortunately, in the
MS-DOS corral, the 2 forms are anything _but_ equivalent.

MS-DOS is single-threaded, so to do the first form, DOS captures the
output of type, writes it to a temporary file (invisible to the user,
because it disappears before you regain control), then executes
tiny-dabe, feeding this temp file to it as stdin. Thus 2 passes and some
extra disk space are used. 

The second form acts in exactly the same way, without the intervening
temporary files. DOS != UNIX... (I wish it did!)
-- 
_R_o_y _M_. _S_i_l_v_e_r_n_a_i_l  | UUCP: uunet!comcon!roy  |  "Every race must arrive at this
#include <opinions.h>;#define opinions MINE  |   point in its history"
SnailMail: P.O. Box 210856, Anchorage,       |   ........Mr. Slippery
Alaska, 99521-0856, U.S.A., Earth, etc.      |  <Ono-Sendai: the right choice!>

ggw@wolves.uucp (Gregory G. Woodbury) (03/09/90)

In article <344@comcon.UUCP> roy@comcon.UUCP (Roy M. Silvernail) writes:
>ggw@wolves.uucp (Gregory G. Woodbury) writes:
>> brad@looking.on.ca (Brad Templeton) writes:
>> >The concept of
>> >	type foo | tiny-dabe >abe.arc
>> >is silly.  It is not meant to be a filter in this manner.  You would use
>> >	tiny-dabe <foo >abe.arc
>> 
>> 	Uhm, Brad.  These two forms are equivalent.
>
>Gregory, the original comment came from me. UUnfortunately, in the
>MS-DOS corral, the 2 forms are anything _but_ equivalent.

	Urr, umm, (let me wipe the egg off of my face here ;-)

	The "effect" of the two forms are equivalent!  I did not mean to
imply that there was no difference in the actual actions performed.  Nor
did I mean to imply that the posters were "wrong" in any sense.  Please
excuse this addle-pated "stupid *nix freak" for typing before engaging
the brain clutch.
	It is hard to remember that not everyone has the luxury of a
personal '386 with lots of memory and space and the ability to collect
enough stuff so that the unix and dos environments that I deal with are
as similar as possible.
	My apologies for the wasted bandwidth.
-- 
Gregory G. Woodbury
Sysop/owner Wolves Den UNIX BBS, Durham NC
UUCP: ...dukcds!wolves!ggw   ...dukeac!wolves!ggw           [use the maps!]
Domain: ggw@cds.duke.edu  ggw@ac.duke.edu  ggw%wolves@ac.duke.edu
Phone: +1 919 493 1998 (Home)  +1 919 684 6126 (Work)
[The line eater is a boojum snark! ]           <standard disclaimers apply>

kjh@pollux.usc.edu (Kenneth J. Hendrickson) (03/18/90)

The commands:

type foo | bar > output     !=     bar < foo > output

in MS-DOS, even though the final result is the same.  MS-DOS, brain-dead
as it is, writes to an intermediate file in the first case listed above.

Question:  Is there any way to force MS-DOS to use a ramdisk for the
intermediate file?  MS-DOS seems to use the current directory, so cd'ing
to the ramdisk would work, but sometimes I don't want the ramdisk to be
the current working directory.

If it is possible to do this, it might make things faster.  I still
won't like MS-DOS, however, because things like:

bar | tee foo | more

can't work like they should (and do on a real O/S).

Ken Hendrickson N8DGN/6      kjh@usc.edu      ...!uunet!usc!pollux!kjh