Subject: Re: using cat on binary files (CTRL-Z trauma)
From: [email-masked] (DJ Delorie)

30 Oct 1996 10:49:26 -0800
Sender: [email-masked]
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Original-To: [email-masked]
Original-CC: [email-masked]
In-reply-to: <[email-masked]> ([email-masked])
Original-Sender: [email-masked]

> > If you want to know why CRLF is the standard, try this command on a unix
> > box:
> > 
> > 	stty -onlcr -icrnl
> > 
> > Note that MS-DOS does not have, nor has ever needed, an stty command.
> 
> Funny, but my unix system continues to run even when I delete this command
> from the disk.

Try deleting the corresponding function out of your shared libc, and I
think you'll find it hard to log in.  stty isn't normally needed
because getty does it for you, but the default is to convert CRs and
LFs in both directions.  In order to claim that you don't need stty
(or its functionality), you must first disable all the conversions
that stty has set up for you when you logged in.

> stty has nothing to do with how lines are stored in files.

Yes, it does, sort of.  If you run "cat file" or "lpr file" and you
don't convert to CR/LF on the way, you can't read the output easily
because there are no carriage returns.  In the ancient days, CP/M (and
its predecessors) stored the CR right in the file so that when it was
printed or sent to the screen (heck, in the old days, your screen
*was* a printer), the CRs were there to move the print carriage back
to the left margin.

Thus, the files had both CR and LF because they needed those control
characters to control the printer.

Since Unix doesn't store the right control characters in the file, it
must allow the user to specify how newlines are to be converted for
their terminals.  Need a CR?  Use "stty onlcr".  Don't support lower
case?  Use "stty olcul".  Return key generates CR instead of LF?  Use
"stty icrnl".

Personally, I think they should have added a separate NL control code,
that meant CR/LF, but they didn't.
-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".