1. 58

  2. 16

    A TTY-related fact that wasn’t mentioned in the article:

    To control text-formatting on an ANSI-compatible terminal (or emulator), you can send it terminal control sequences like \e[1m to enable bold or whatever. Paper-based terminals didn’t have control-sequences like that, but people still figured out ways to do formatting. For example, if you printed a letter, then sent backspace (Ctrl-H, octet 0x08) and printed the same letter again, it would be printed with twice as much ink, making it look “bold”. If you printed a letter, then sent backspace and an underscore, it would look underlined.

    The original Unix typesetting software took full advantage of this trick. If you told it to output a document (say, a manpage) to your terminal (as opposed to the expensive typesetting machine in the corner), it would use the BS trick to approximate the intended formatting.

    This worked great, up until the invention of video display terminals, where the backspace trick just replaced the original text, instead of adding to it. So people wrote software to translate the backspace-trick into ANSI control codes… software like less(1).

    If you run:

    printf 'H\x08He\x08el\x08ll\x08lo\x08o w\x08_o\x08_r\x08_l\x08_d\x08_\n'

    …in a modern terminal emulator, you’ll probably get output like:

    Hello _____

    …because that’s how glass TTYs work. However, if you pipe it through less(1):

    printf 'H\x08He\x08el\x08ll\x08lo\x08o w\x08_o\x08_r\x08_l\x08_d\x08_\n' | less

    … it will convert the backspace trick into formatting your terminal can understand. Unfortunately, I can’t figure out how to represent it in Markdown, so you’ll have to try it for yourself!

    1. 8

      Indeed, this is how man(1) formats manual pages. One could try PAGER='cat -v' man ls with GNU cat(1) (nonstandard -v option) to see all the ^H’s in their full glory.

      Something else that I felt was missing from the article that would be nice to add is about DEL: it’s separate from the other control sequences, located in the far end as value 0x7F. But why? Turns out, back when paper tapes were still relevant, it is a useful property to have the DEL sequence be “all bits set”, because you can always overstrike existing data with more holes—which means you can take an existing tape and DEL out data.

      1. 5

        See also ul(1) … so common it got one of the two-character command-names.

      2. 16

        Now this article I can get behind! While I often find Mr. Raymond’s opinion pieces objectionable and occasionally out and out wrong, but in my view his work really shines when he strives to educate, and this article is a great example.

        I wish there were a bit more depth on UUCP, but overall - great article. Thanks for posting it.

        1. 9

          Indeed. In pre-Wikipedia days, the Hacker Dictionary was a valuable source of computer history: as an undergrad not near MA or CA in the late 90’s, who would know about ITS or TOPS-20, why EBCDIC was feared, and what “Dragon book”, “PEBKAC”, or “molly-guard” meant?

          Even if an original version has since been found, ESR’s was valuable at the time since it was on the Web and at least pointed out next steps for looking.

          The only thing I’ll note about this essay is that Field/Record separators have made a slight comeback in certain situations. I’ve been using FS in some shell scripts where I can’t guarantee that commas, pipes, or other text chars won’t show up to mess with CSV delimiters.

          1. 4

            I still own my NHD 2nd edition :)

            It’s got some stuff that’s since been removed, like the Friar Tuck & Robin Hood story :) (Old multiprocess exploit for a Xerox computer)

            I found it on the web here: http://www.catb.org/jargon/html/meaning-of-hack.html

          2. 8

            My sentiments exactly. I stopped visiting his sites a few years ago; the signal to bombast ratio was just too low for me. If it weren’t for postings on aggregators, I’d miss great articles like this.

          3. 7

            Interesting to know that there’s some logic to what the control and alt/meta keys on a keyboard are doing, in terms of the ASCII representation of the keys they modify.

            1. 5

              I completely forgot about the existence of UUCP. What a lovely trip down memory lane. Thanks for posting. :-)

              1. 3

                i am reminded of one of my favourite dos-era programs, helppc. someone has converted it to html; it lacks the old-school charm of the TUI version but it’s still a good resource.

                1. 3

                  RS-232 didn’t finally disappear from general-purpose computers until around 2010

                  RS-232 is far from dead in my world.

                  I have null modem cables on RJ45 ports of T1000/T5220 sparc64 servers and edge router lite, DB9 serial ports for a sparc64 blade100 and a few x86 PCs and alix/soekris/apu boards, and over USB on BeagleBoneBlack and ADI boards.

                  Granted, none of my machines (except a sparc ultra 1) use the classic 25 pin connector. But the only machines I don’t normally use a serial console with are laptops.

                  Even my desktop computer has console on serial so in case it falls into ddb while I’m not at home I can diagnose and attempt a reboot remotely.

                  edit: found another machine with serial to add to the list :)

                  1. 2

                    Agreed. Physically wired serial consoles for servers are very much alive in our world (a midsized university department), and it’s very common for server hardware to still come with them. Sometimes you’re talking directly to the server, sometimes to its IPMI (with a pass-through to the server’s serial console available). And companies like Digi International (with their Etherlite series) still do good business in selling serial concentrators and serial to Ethernet bridges so you can conveniently connect all those server serial consoles up to a console server.

                    Similarly, a lot of higher end networking switches and routers still have serial consoles and can be configured and managed over them, although lower-end switches have mostly moved to web management only (probably because it lets them skip the serial port connector and hardware that would otherwise be required for it).

                  2. 3

                    “Hackers of a certain age still tend to have these things cluttering their toolboxes or gathering dust in a closet somewhere.”

                    ACK! I’m of a certain age! Oh well, I’m proud of it.

                    RS232 is still very common in the network hardware arena, although you don’t see the old DB9 connectors as much anymore. The RJ45 port on your router labeled ‘console’ that doesn’t link up when you plug it into a switch is usually a three wire RS232 serial port, and you’ll need a small pile of adapters to talk to it.

                    1. 1

                      Another significant problem was that an RS-232 device not actually sending data was undetectable without analog-level monitoring equipment. You couldn’t tell a working but silent device from one that had come unplugged or suffered a connection fault in its wiring. This caused no end of complications when troubleshooting and is a major reason USB was able to displace RS-232 after 1994.

                      That’s not the main reason (I rarely had to troubleshoot an unplugged/broken RS-232 cable), it was the fricken “7E1” or “8N1”? What baud/bps? Did I configure the UART correctly via the dipswitches? etc. All that guessing as to why the darn things couldn’t talk to each other. Once USB came out, all those issues went away. That’s why USB won.