[comp.text] meaning of newlines

tbray@watsol.waterloo.edu (Tim Bray) (02/15/91)

tut@cairo.Eng.Sun.COM (Bill "Bill" Tuthill) writes:
 The world's three most important operating systems-- Unix, MS-DOS,
 and MacOS-- all employ different methods for separating lines from
 each other....
 That is, do any of these three operating systems have
 any justification (other than space savings in the case of Unix and
 MacOS) for doing things they way they did?

Depends what you mean by a line.  If you mean "visual breaking-up of
a sequence of text to fit on a page", DOS is closest to right, since such
breaking-up is in fact accomplished by a motion to the left margin (CR) and
a motion down (LF).  If you mean "record separator in a file whose elements
happen to be mostly 7-bit ASCII" then there is no particular argument
either way, and the most compact is probably the best.

The problem is that Unix has historically kludged this by overloading the
semantics of the '\n' character, using it both as a record separator (viz.
/etc/passwd) and having the terminal driver capable of special behavior to
produce nice-looking "lines" of text.

This is fine in most of the cases.  However, when you get a complex piece
of text with no natural "record" divisions (and one of the strengths of
Unix is that it has freed us, by and large, from the tyranny of record-
orientedp processing), this overloading of '\n' really begins to bite.
To start with, vi, sed, grep, and so on stop working if you don't have
enough '\n' characters.

Anyhow, I had a sermon on this subject in my paper of the Winter '89 Usenix...

Cheers, Tim Bray, Open Text Systems