[comp.sys.ibm.pc] Historical question: LF vs. CR\LF in text files

tomr@ashtate (Tom Rombouts) (05/30/90)

Forgive the bandwidth, but seeing that others beside myself are
having occassional problems relating to the differences between
UNIX vs. DOS (and CP/M, correct?) in handling end of lines, I am
wondering how this started.  Since UNIX came first, I am going to
guess that at some time, somewhere someone said "Hey - let's add
a carriage return!"  Does anyone know the (possibly amusing?) story
behind this?  What was the essential rationale?

Tom Rombouts, Torrance Techie  Voice: (213) 538-7108

mwarren@mips2.cr.bull.com (Mark Warren) (05/30/90)

In article <952@ashton.UUCP> tomr@ashton.UUCP (Tom Rombouts) writes:
> ... relating to the differences between
>UNIX vs. DOS (and CP/M, correct?) in handling end of lines, I am
>wondering how this started.  Since UNIX came first, I am going to
>guess that at some time, somewhere someone said "Hey - let's add
>a carriage return!"
>
"Unix came first" ????  Ulp!  Makes me feel pretty old.  The simple
history relates to the olden days, when boys were boys, men were men,
and advanced computer terminals were Teletype Corp. ASR33's with cute
little 10 cps paper tape readers on the side.  Quite simply, as in a
standard typewriter (the old fashioned kind that did not have a
computer attached, or even an electrical cord), the real physical
indication of the end of a line was a carriage return, followed by a
new line.
-- 

 == Mark Warren                      Bull HN Information Systems Inc. ==
 == (508) 671-3171 (FAX 671-3020)    300 Concord Road     MS820A      ==
 == mwarren@granite.cr.bull.com      Billerica, MA 01821              ==

toma@tekgvs.LABS.TEK.COM (Tom Almy) (05/30/90)

In article <952@ashton.UUCP> tomr@ashton.UUCP (Tom Rombouts) writes:
>Forgive the bandwidth, but seeing that others beside myself are
>having occassional problems relating to the differences between
>UNIX vs. DOS (and CP/M, correct?) in handling end of lines, I am
>wondering how this started.  Since UNIX came first, I am going to
>guess that at some time, somewhere someone said "Hey - let's add
>a carriage return!"  Does anyone know the (possibly amusing?) story
>behind this?  What was the essential rationale?

Turning back the clock, one delt with "records" where typically one
record equaled one line. There were no "carriage returns" or "line feeds".
But then (ignoring Flexowriters and other early terminals I never had the
chance to use) along came ASCII and the Teletype Model 33. ASCII defined
separate codes for the carriage return (which actually returned the print
head on the model 33, but at least it was a mechanical motion) and line
feed (which actually fed paper). The early *pre-UNIX* operating systems
tended to have these two characters represent the end of line because that
is what it took to run the printer.

Of course things weren't completely simple because one didn't want to hit
both the carriage return and line feed keys on the Teletype to enter lines
(you had to do this if you were in Off-Line mode) so carriage returns were
converted to cr/lf pairs on input. Also the extra byte did waste precious
storage.

I had used some systems that compressed the eol sequence to a single character
before UNIX existed (more later...).

UNIX didn't say "lets get rid of the carriage return and just use the line
feed". It invented a new code "new line". It just so happens to be internally
represented with the same code as the ASCII line feed. The TTY driver has
the responsibility of translating CR->NL on input and NL->CR/LF on output.
Note that the driver allows turning the translation off. About 10 years ago
I wrote a terminal emulator program that emulated a "UNIX" terminal -- the
carriage return key sent a "New Line", and the receipt of a "New Line" caused
a carriage return/line feed operation. This didn't last long because of
all the programs that ended up switching to RAW mode to bypass the conversion
behaved very poorly!

I have used several systems that went the single character route using the
Carriage Return. This is probably the most sensible because input conversion
is not necessary. Also standard typewriter practice is that the carriage
return operation (either key or lever on a manual typewriter (remember those?))
would also advance the line, but yet line advance could be independently
performed (with the knob on the end of the carriage).

I know that the net is full of UNIX-myopic people, but UNIX was not first nor
did it make the best move on this one.

Tom Almy
toma@tekgvs.labs.tek.com
Standard Disclaimers Apply

ergo@netcom.UUCP (Isaac Rabinovitch) (05/31/90)

tomr@ashtate (Tom Rombouts) writes:

>Forgive the bandwidth, but seeing that others beside myself are
>having occassional problems relating to the differences between
>UNIX vs. DOS (and CP/M, correct?) in handling end of lines, I am
>wondering how this started.  Since UNIX came first, I am going to
>guess that at some time, somewhere someone said "Hey - let's add
>a carriage return!"  Does anyone know the (possibly amusing?) story
>behind this?  What was the essential rationale?

Unix came before micro OSs, but the CR/LF convention is older than
Unix -- in fact it's older than computers, having been used on
electromechanical teletypes.

The developers of Unix didn't merely drop the carriage return character.
They renamed the line feed character "newline".  At the time some people
objected to this, pointing out that there was now no "down one line"
character.

Note that initially CP/M (and MS-DOS, which started out as a CP/M clone)
imitated pre-Unix mini OSs.  MS-DOS didn't start adding Unix-like features
until later.

meissner@osf.org (Michael Meissner) (06/01/90)

In article <12661@netcom.UUCP> ergo@netcom.UUCP (Isaac Rabinovitch)
writes:

| The developers of Unix didn't merely drop the carriage return character.
| They renamed the line feed character "newline".  At the time some people
| objected to this, pointing out that there was now no "down one line"
| character.

In the eight bit world which uses ASCII as a subset, there is a Next
Line byte.  We had great fun in the X3J11 committee when it was
discovered that the appropriate standards body for character sets was
trying to obsolete the use of linefeed as a newline character.
--
Michael Meissner	email: meissner@osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA

Catproof is an oxymoron, Childproof is nearly so

guy@auspex.auspex.com (Guy Harris) (06/01/90)

 >The developers of Unix didn't merely drop the carriage return character.
 >They renamed the line feed character "newline".  At the time some people
 >objected to this, pointing out that there was now no "down one line"
 >character.

FYI, folks, UNIX came *after* Multics, and Multics used the LF character
as "newline".  UNIX didn't invent the idea....