Subject: Re: cat(1) question: multiple "-"s
To: Andrew Smallshaw <>
From: matthew sporleder <>
List: netbsd-users
Date: 04/18/2006 22:16:02
On 4/18/06, Andrew Smallshaw <> wrote:
> On Tue, Apr 18, 2006 at 03:17:11PM -0400, matthew sporleder wrote:
> >
> > 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
> (I think you got your 1's and 2's crossed there, but I understand what yo=
> mean)


> This is _not_ what is supposed to happen. A - in the command line means t=
> get some new standard input for each occurance.  A straight 'cat - -' wil=
> get two files from the terminal - you have to press ^D twice, and further
> data can appear after the first.  An explanation of this in more depth
> really does require at least a basic knowledge of C - as an example I am
> referring to some code I wrote a while back which you may find at:

I agree that when interactively called, stdin should be prompted.=20
However, when stdin is passed with <file (or any other sort of
non-interactive way) I still think my way makes sense, whether called
from a terminal or not (probably a difficult distinction).  Although I
do admit that netbsd's cat performs the same as solaris, osx, and
linux, so it's probably not very good to try changing it.  :)

I think you just have to add a rewind() to stdin on non-interactive
shells to make things work that way.  At least, I did it pretty easily
with perl and seek.