Subject: Re: cat(1) question: multiple "-"s
To: Hubert Feyrer <hubert@feyrer.de>
From: matthew sporleder <msporleder@gmail.com>
List: netbsd-users
Date: 04/18/2006 15:17:11
On 4/18/06, Hubert Feyrer <hubert@feyrer.de> wrote:
>
> From cat(1):
>
>       The cat utility reads files sequentially, writing them to the stand=
ard
>       output.  The file operands are processed in command line order.  A =
single
>       dash represents the standard input, and may appear multiple times i=
n the
>       file list.
>
> What sense do multiple appearances of '-' make on the cat command line,
> how is that supposed to work?

I think The Right Thing should be that cat will interpret many -'s as
"output stdin where - appears"

I think the right thing is:

(file1 contains 111 and file2 contains 222)
cat - file1 - <file2

Should print:
111
222
111

This would match the behavior of:
cat file2 file1 file2
does print:
222
111
222

Using multiple < redirections should not work as an array/list of
stdin's.  If you want to do that, you should add options to cat to
read random filehandles, or something weird like that.  (cat -&3 -&4
3<file2 4<file1 or some other weirdness)