Subject: Re: using cat on binary files (CTRL-Z trauma)
From: [email-masked] ("Shane Kerr")

28 Oct 1996 21:07:08 -0800
Sender: [email-masked]
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Comments: Authenticated sender is <[email-masked]>
Original-To: Geoffrey Noer <[email-masked]>, [email-masked]
X-mailer: Pegasus Mail for Win32 (v2.42a)
Original-Sender: [email-masked]

> John Cook taps on the keyboard:
> > 
> > ...And if CTRL-Z is _not_ an EOF character, then why does cat
> > behave this way within Windows NT?  Is cat not intended for binary
> > files under Win32 environments?
> 
> The problem in this case seems to be that many Unix programs don't
> specify O_BINARY when appropriate.  Since cat always works in text
> mode, control-Z gets trapped as EOF even when it shouldn't.

Many UNIX programs don't specify WHAT???  O_BINARY is strictly a 
MS-DOS artifact.  Well, maybe Mac's have it, I don't know.  There 
_is_ no O_BINARY flag in UNIX, so I would hazard to guess that there 
are _very_ few UNIX programs that use it.

> I've added this as a known bug to look into.  For now, it would be
> best to avoid catting binary files.

I would suggest that for maximum compatibility files should default 
to binary mode.

> For backwards compatibility, we will probably have to keep around
> the Control-Z as EOF support for quite a while.  This shouldn't be
> an issue as long as binary files are recognized as such.

In UNIX, Control-D typically serves to mark the end of input from a 
TTY, although this can be set via a stty.  In MS-..., I mean Win32, 
it would seem to make sense to have Control-Z count as EOF from the 
console, but not in files.

Just my $0.02.
-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".