The End-of-Line Story (2004)
rfc-editor.org
rfc-editor.org
Teletype machines needed a delay to move the printing apparatus back to the beginning of a line. The two characters provided that delay.
I never used one of these; I was too young.
It particularly interesting to send control codes to see what they made the printer do. Pressing <ENTER> got carriage returns without advancing the platen (so you could type over and over again on the same line). <CTRL><L> made the printer advance to the next page of the fan fold. <CTRL><G> made the printer beep.
I figured out that <CTRL><H> moved the print head backward. I used this to make some "impossible to print" output (that is, impossible for my word processor to reproduce because it wouldn't send backspaces for the purposes of over-printing).
Later, during my youthful phase of probing systems on various networks, I ran into systems that, upon entry of a bad password, would send a series of backspaces, various random letters, pound signs, and asterisks before giving a new logon prompt. At the time I didn't put two and two together. (I hadn't yet read Levy's "Hackers" and the idea of using a teletype as an input device on a computer wasn't a thing I'd heard about yet.)
Years later, looking at old captures and seeing this seemingly strange series of characters, I realized what the purpose was. The characters were being sent to obliterate the password printed by your teletype's local echo.
(I want to say the OS was PRIMOS but I don't remember for sure. I saw a number of them on either Tymnet or Telenet-- maybe both.)
So, two commands were needed on those teletypes because of how they work, not to introduce any delay. It's possible the baud rate could be slow enough such that all the mechanical movements are wrapped up during the transmission of two characters. But sometimes you need to insert a delay after an EOL, something you can set on lots of serial port terminal emulators (although that's usually done for different reasons). You can set a delay in the termcap parameters to account for this needed delay. I'm not sure if any of the common mechanical teletypes offered a handshaking line to hold off the computer until the motion stopped, but that would have been another option -- and a faster solution, since the delay time would be exactly what was needed (vs a maximum fixed delay of a software solution).
Those teletypes were originally meant to be used in teletype to teletype operations, where the maximum baud rate was fixed by the mechanical operation of the printing mechanism. If you interfaced a 60 baud TTY to a computer running at 9600 baud, you also have to delay between each character, not only at the EOL. I know this because I foolishly interfaced my Commodore C64 back in college to an old Army surplus Kleinschmidt TT-4 mechanical teletype. I had to deal with these delays, as well as converting the parallel ASCII of the C64 to the serial Baudot needed by the TT-4.
edit: I suppose they settled on CR/LF instead of LF/CR, because the former could be a little but quicker... the LF could be performed while the carriage was traveling back to the start of line. But that's just a guess.
This compromise might have made sense from a political or goodwill standpoint at the time. But it meant that everyone using these protocols would have to store, convert, or transmit the extra character forever.
Kermit was the file transfer protocol of last resort for sorting out weird translation issues. It was slow but super effective.
HN is +10 proof against ascii art.
Nowadays I tend to enforce LF everwhere. Windows can deal with it, and it ensures consistent cross platform handling. I know that Rust also uses a single LF on all platforms, not sure if there are other such languages.
Some "text protocols" have CR LF line endings but this should be relegated to a library; your own code shouldn't deal with this.
And then we can all forget this mistake
People today forget or don't realize how provincial and siloed computing used to be. Even as late as the 90's it was very common for institutions to have multiple LAN's that were isolated from each other simply due to platform incompatibility.
while [ "$url" ]; do
res=$(curl -i "$url" | tr -d '\r')
headers=$(echo "$res" | sed '/^$/q')
body=$(echo "$res" | sed '1,/^$/d')
echo "$body"
url=$(echo "$headers" | sed -n -E 's/link: <(.*)>; rel="next"/\1/pi')
done