An odd difference between "cat file" and "cat<file"

Mark Brader ntt at dciem.UUCP
Thu Apr 19 09:12:43 AEST 1984


Alan Driscoll (allegra!alan) says:

	I would also have expected an error message after typing
		cat < abc abd
	In fact, both sh and csh silently ignore 'abc'.  (Surprise!)

But look, the following command is perfectly legitimate and useful:
	ed < abc abd
It means to edit file abd according to the script in abc, of course.

Obviously the shell has no business knowing the difference between the
behavior of "cat" and "ed".  And "cat" is behaving according to documentation;
it is supposed to copy the standard input to the standard output only when
no input file names were specified.

Do you want "cat" to give an error message when a file name is specified
and the standard input has been redirected?  Then what happens when "cat file"
occurs in a shell script whose standard input has been redirected?

It ain't broke, don't fix it.
Mark Brader

P.S. I, too, would like to see "cat <ab*" accepted when "ab*" expands
uniquely -- but it looks like too much trouble to me.  What do you do
when the "<" is a ">" and there is no match, by the way?



More information about the Comp.unix mailing list