Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site mulga.SUN
Path: utzoo!watmath!clyde!floyd!harpo!decvax!mulga!kre
From: kre@mulga.SUN (Robert Elz)
Newsgroups: net.unix-wizards
Subject: Re:  4.2BSD _filbuf() question
Message-ID: <192@mulga.SUN>
Date: Mon, 23-Jan-84 21:20:30 EST
Article-I.D.: mulga.192
Posted: Mon Jan 23 21:20:30 1984
Date-Received: Wed, 8-Feb-84 07:17:42 EST
References: <15476@sri-arpa.UUCP>, <141@taurus.UUCP>
Organization: Comp Sci, Melbourne Uni, Australia
Lines: 49

>  the documentation for the cat command reads:
>  
>  	"if the argument `-' is encountered, cat reads from the
>  	 standard input file"
>  
>  (ok, thats not from the 4.2 manual - i hope it's the same!)

It is (approximately) that in the 4.2 manual.

>  
>  this implies to me that
>  	cat - a - b - c > d
>  should read the standard input three times allowing me to enter titles.

It does just that, it reads standard input 3 times, just that
the change to _filbuf has made reads to stdin return EOF after
one EOF has been encountered, until that condition is explicitly
reset.

Whether that is the right thing for _filbuf to do is the point
under debate.  My thoughts are given by the following example ...

What does
	cat - a - b - c > d < e
produce in file 'd'?   (I don't care what system that you run this on).

Then ask yourself:  Why should it matter whether or not I made
'e' by  "cp file e" or "mknod e c maj min"  (fill in major & minor
from your own system for some terminal device, or mag tape, or ...).

The whole idea of device independant i/o is to provide similar
(at least) operation, whatever kind of beast is connected
to the file descriptor.

The change to _filbuf is a bug fix, and its immaterial how
long the bug had been there, and immaterial who or what
looks on this bug as a "feature", and exploits it for all its worth.

>  
>  i'd say it's cat's fault for treating `-' as a special case rather
>  than opening and closing the tty like it would any other file.
>  

If that's what you really want cat to do (that is, read your terminal
several times) then using "/dev/tty" will do it quite nicely.  However, of
course, "-" does not mean your tty, it means standard input, which
is not the same thing at all.

Robert Elz,  Melbourne Uni Comp Sci,		decvax!mulga!kre