www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1996/10/28/09:14:18

From: hgeleff AT logos DOT cy DOT net ("Henrik Geleff")
Subject: Re: using cat on binary files (CTRL-Z trauma)
28 Oct 1996 09:14:18 -0800 :
Sender: daemon AT cygnus DOT com
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <199610281747.TAA11664.cygnus.gnu-win32@zenon.logos.cy.net>
Mime-Version: 1.0
Original-To: <gnu-win32 AT cygnus DOT com>
X-MSMail-Priority: Normal
X-Priority: 3
X-Mailer: Microsoft Internet Mail 4.70.1155
Original-Sender: owner-gnu-win32 AT cygnus DOT com

I do think it is correct for cat to pick CTRL-Z as an end of file on the
DOS/Windows/NT platforms, the CTRL-Z has been inherited by these platforms 
from CP/M, which was not able to determine how much of the last sector
actually was file contents. Basicly:

- cat was intended to show text files -- cat'ing binary files to an ASCII
terminal can bring the terminal into a state which you can not escape from
in an orderly manner (i.e. logging out).

- CP/M, later MS-DOS, later Windows, later NT have kept the tradition of
using CTRL-Z as EOF character (although the reason has ceased to exist),
and such a long tradition should be honoured.

Anybody wanting to see the contents of a binary file can use od -c or if
only the text is wanted strings.

Regards
Henrik Geleff

----------
> From: Geoffrey Noer <noer AT cygnus DOT com>
> To: John Cook <jcook AT mseng DOT kla DOT com>
> Cc: gnu-win32 AT cygnus DOT com
> Subject: Re: using cat on binary files (CTRL-Z trauma)
> Date: 28 October 1996 11:22
> 
> John Cook taps on the keyboard:
> > 
> > Thank you for this clarification...  I am still looking for an answer
> > to my main question, however:  Is there a way to prevent cat from
> > quitting when it finds a CTRL-Z in its input under either the Win32
> > console or GnuWin32 bash?
> > 
> > ...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.
> 
> I've added this as a known bug to look into.  For now, it would be
> best to avoid catting binary files.
> 
> 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.
> 
> -- 
> Geoffrey Noer
> noer AT cygnus DOT com
> -
> For help on using this list, send a message to
> "gnu-win32-request AT cygnus DOT com" with one line of text: "help".
-
For help on using this list, send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019