Subject: Re: cat(1) question: multiple "-"s
To: Hubert Feyrer <hubert@feyrer.de>
From: Simon Burge <simonb@wasabisystems.com>
List: netbsd-users
Date: 04/19/2006 11:02:16
Hubert Feyrer wrote:

> >From cat(1):
> 
>       The cat utility reads files sequentially, writing them to the standard
>       output.  The file operands are processed in command line order.  A single
>       dash represents the standard input, and may appear multiple times in the
>       file list.
> 
> What sense do multiple appearances of '-' make on the cat command line,
> how is that supposed to work?

SUSv3 talks about this a little, saying that it really only makes sense
for when standard input is a terminal:

     The command:

	cat start - middle - end > file

     when standard input is a terminal, gets two arbitrary pieces of
     input from the terminal with a single invocation of cat. Note,
     however, that if standard input is a regular file, this would be
     equivalent to the command:

	cat start - middle /dev/null end > file

     because the entire contents of the file would be consumed by cat
     the first time '-' was used as a file operand and an end-of-file
     condition would be detected immediately when '-' was referenced the
     second time.

I'll leave the zsh part of the discussion well alone :-)

Cheers,
Simon.
--
Simon Burge                            <simonb@wasabisystems.com>
NetBSD Support and Service:         http://www.wasabisystems.com/