Email or username:

Password:

Forgot your password?
Top-level
Hans Hübner

@b0rk It is worthwhile to think of "Unix" and "readline" separately.

"Unix" provides terminal driver functionality, and cooked mode is part of the driver. Originally, all line editing functionality was provided by the tty driver, and different Unix variants had different features. The BSD driver was way more feature rich than the Unix System V driver. One thing all Unix tty drivers have in common, however, is that they have programmable control characters.

1/

16 comments
Julia Evans

@hanshuebner I don't really understand what you mean, I think it's obvious that "readline" exists at a very different level than the terminal driver?

what's interesting to me is that from a user’s perspective it's very unclear which things are being handled by the OS and which are passed through to the application and they're just kind of chaotically mixed together

Hans Hübner

@b0rk I don't think that it is all that obvious that readline is not part of the driver. Providing kernel-level line editing basically was a necessity in the 16bit era, but when machines got more powerful, providing these things in user mode became more common.

What that also meant is that there was no single line editing system, but each user-mode program could (and needed) to provide its own. GNU readline, albeit popular, was really hindered by its license.

Hans Hübner

@b0rk With a user-mode line editor, it is only the control characters that generate interrupts which require driver support, and modern implementations don't even need to rely on the driver to send signals (i.e. they treat Ctrl-C like any other character and send a SIGINT if they want to).

Hans Hübner

@b0rk The defaults for the control characters varied between systems. System V originally had @ as the kill character and DEL as interrupt, which was rather annoying when you used a terminal that had DEL where you would have the BS key.

When machines got faster, it became feasible to have a user-mode line editing program do the input processing. tcsh was the first popular shell to have line editing with arrow key support. ksh provided vi-style editing in a hybrid setting.

2/

Hans Hübner

@b0rk I bore you with these historical details because I think that the question "what control characters does Unix use" cannot really be answered on that level in a meaningful manner. It may make sense to discuss common driver-based and user mode line editing facilities, but generally, in the Unix world, they are all configurable and the defaults changed over time.

Other systems (i.e. VMS or DG/OS) were way less flexible, which meant that they required specific terminals.

3/3

Julia Evans

@hanshuebner hmm it feels a lot more fixed to me than that, like I know there are a lot of unixes out there but personally as someone who has only ever used Mac and Linux machines and would absolutely never change my `stty` settings in a million years, for me there are a lot of assumptions it's very fair to make about how these things are going to work

like it's hard to imagine that very many people are going to remap SIGINT to something other than Ctrl-C even if theoretically you can

Hans Hübner

@b0rk I don't disagree. I guess for most people, the fact that a terminal driver exists and can be misconfigured is just a historical nuisance and not something that they can or need to take advantage of.

Julia Evans

@hanshuebner for me it's useful to know about the terminal driver because it means that when I’m using some terrible program without line editing support (which happens more often than I'd like!) I know that the terminal driver will still let me do `Ctrl-W` or `Ctrl-U` when I make a mistake

Hans Hübner

@b0rk Absolutely! This is why I think that tty driver functionality and user-mode line editing behavior deserve separate treatment. I think it is still useful to know that the driver exists and when it is active. Also, it is worth knowing that BSD derived systems have the status character (Ctrl-T) and that incorrect setting of the erase character can bite you.

Julia Evans

@hanshuebner thanks, I just learned that Ctrl+H is sometimes backspace today

wfk

@b0rk in a literal sense, ctrl-H *is* backspace. The ERASE function in termios has historically been set to either DEL or BACKSPACE, depending on the keyboard layout and configuration of the terminal being used. This is why many terminal emulators still have a configuration setting to indicate what the Backspace/DEL/<- key on your keyboard should generate. Whether user space code honours the termios setting when running in raw mode depends on the user space code...

Julia Evans

@wfk on my machine ctrl-H is not backspace, would be curious to see the output of stty -a on your machine to see how it works there!

wfk replied to Julia

@b0rk we may be using different definitions of backspace here. I suspect you are talking about what is named the ERASE function in termios: undo the previously typed character on the line. I use backspace in the ASCII meaning, which is the ASCII code associated with ctrl-H. If your keyboard does not generate that ASCII code when you press ctrl-H, that's a seriously non-standard setup. This is a function of the terminal (emulator), not of the tty driver.

Julia Evans replied to wfk

@wfk yea I guess what I'm trying to figure out is whether 0x08 has much of a real purpose today or whether it's mostly cruft

Eli the Bearded

@b0rk @hanshuebner
As an example, the tty level driver is operating when you are in password entering mode. The readline functions will not be there, but tty level backspace, delete word, and delete line will be.

And people who want to can reset tty or readline config, but they are controlled in different ways.

(I disable emacs style editing everywhere I can use vi style.)

Raven667

@hanshuebner talking about software maintenance, the context around it changes which changes what design and abstraction makes sense. Given today's terminal context, maybe one could design a new tty layer that is much simpler by making more assumptions about the capabilities of the terminals and apps.

Go Up