On Wed, Mar 30, 2005 at 04:51:24PM -0500, Bill McGonigle wrote: > On Mar 29, 2005, at 22:02, Ben Scott wrote: > > >One thing I've always admired about Unix is that it no other system > >has more trouble going backwards.... > > It's true - why is this so hard? Is there a design deficit or just a > common programming mistake? I think it's not a design deficiency at all -- in fact I think the design is quite good. The design takes into account that historically people connected a wide array of (potentially) vastly different terminals to Unix machines, and still had get them all to generate more-or-less the same characters.
The problem of handling input from terminals of various design is a surprisingly complicated one... On one level, you have the terminals themselves: what keys generate what key codes. Then at the system level, you have to interpret what those key codes are supposed to mean. In many cases (such as with the X Window System) you have a third layer of terminal emulation that gets stuck in the middle. It's amazing that any of this works at all! The idea is that different terminals have different feature sets, and also use different character sequences to represent any given feature. In order to make this all work, you need a layer of abstraction in between the signal generated by the keyboard or terminal (the key code generated by pressing a given key) and the terminal feature it is meant to activate. If you didn't have this layer of abstraction in between, only one brand of terminal would ever work on a given system at one time... Your keyboard generates some key code when you press the backspace key. This code can vary depending on the model of the keyboard you have. The Linux console, and also the X window system, have a key map which translates these hardware-generated key codes into logical characters. Above that layer, you have the terminal driver, and the termcap/terminfo libraries. These interpret which terminal features those logical characters are supposed to activate. So, if your keymap has the wrong key code mapped to the backspace key, it sends the wrong logical character sequence to the terminal driver. Or, if your termcap or terminfo databases list the wrong character sequence for a particular terminal feature (or capability, which is where "termcap" comes from -- TERMinal CAPability), then your I/O will be flummoxed. If both are wrong, well... So really, there are two problems which have lead to the sad state of affairs bollixing up the backspace key. One is bad coding practices -- programs which assume that ^H is supposed to be backspace, or that ^? is, instead of letting the terminal driver do the translation as intended. The second is lazy or ignorant system administrators who have misconfigured termcap/terminfo databases. NOTE: for those who might be inclined to be offended by the use of the word "ignorant" -- I've used the word in its literal sense, meaning "to be unknowing", rather than its popularly bastardized sense meaning roughly, "to be rude, or to be inept or inadequate". > I first remember having to put stty erase commands in my .tcshrc on an > VAX running ULTRIX c. '91. It hasn't really improved since then > (though my FC3 machines seem to behave better). I disagree... discounting the bug under current discussion, I think the situation with backspace has improved dramatically since when I first started using Unix 10 years ago... In recent memory, in homogenous environments, nary an occasion can I recall which the backspace problem has gotten in the way of me accomplishing whatever I was working on. [Again, save this bug in screen...] On the other hand, it does tend to happen when going between different Unix systems, because vendors can't seem to agree on which key sequences the backspace, erase, and/or rub keys should send, nor even what exactly should be done when they have been pressed. And that's assuming the given vendor hasn't decided to call those keys something entirely different... Sigh. Anyway, I think it's much better than it used to be. =8^) -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail. Sorry for the inconvenience. Thank the spammers.
pgpA32ikbbZwu.pgp
Description: PGP signature