Skip to Content
Navigation:

A stick figure smiling

If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript".

browse more comics! get the zine!
read the transcript!

the terminal driver: an interface that hasn’t changed since the 80s

stressed-out stick figure with curly hair, surrounded by question marks: “I pressed an arrow key and it just printed out ^[[D???”

terminal driver, represented by a triangle smiling innocently: “what’s an arrow key?”

when you’re typing text, there are two situations

  1. by default: the terminal driver (part of the OS) is responsible

“canonical mode”

  1. the program is responsible

“raw mode”

“canonical mode” is a terrible way to edit text

because the terminal driver hasn’t changed much since the 80s, you can only do:

  1. backspace
  2. Ctrl+W (delete word)
  3. Ctrl+U (delete line)

how canonical mode works

  1. you type “helll” + backspace

person:

helll
<BACKSPACE>o
<Enter>
  1. the terminal emulator turns what you typed into bytes

terminal emulator, represented by a box with tiny arms and legs and a very cute winking cursor eye: hell\x7Fo\n

  1. the terminal driver passes on “hell” and interprets the backspace

PTMX -> TTY -> hello\n

  1. the program gets “hello\n”

The program is represented by a box with a smiley face, with a little arrow pointing to it, labelled “in”

In canonical mode, terminal driver doesn’t send anything to the program until you press Enter.

In raw mode, the terminal driver just sends “hell\xFo\n” without changing it

how to try out canonical mode

Run cat and type some stuff!

Interactive programs almost never use canonical mode because it’s so limited.

But if you run into it rlwrap $COMMAND can help

Saturday Morning Comics!

Want another comic like this in your email every Saturday? Sign up here!

I'll send you one of my favourite comics from my archives every Saturday.
© Julia Evans 2024 | All rights reserved (see the FAQ for notes about licensing)