2 ms·
Note that, although bash handles this case, the terminal never interprets ^C or backspace or ^U or anything like that. That’s all in the tty driver — see OpenBS
by gnubison 4y ago
Note that, although bash handles this case, the terminal never interprets ^C or backspace or ^U or anything like that. That’s all in the tty driver — see OpenBSD’s termios(4) for information on how to configure it.
In general, “smart” programs like bash or vi or fzf or readline configure the termios state so that the tty driver doesn’t handle any keys. This gives them more control. When they exit, they restore the termios to the original state, so that you can still backspace in dumb programs like cat and grep.
So you might have a dance like this when you run vi:
- bash restores its saved termios, so that whatever program it’s running starts with a blank slate
- vi saves the original termios
- vi switches the termios into “raw mode” (simplification)
- you edit text …
- vi switches back to the state it saved
- vi exits
- bash saves the termios state
- bash switches to raw mode