Subject: Re: An old unix Issue the Delete key how do you fix it
To: None <netbsd-help@NetBSD.org>
From: Pavel Cahyna <pavel@NetBSD.org>
List: netbsd-help
Date: 05/04/2007 20:58:50
On Thu, May 03, 2007 at 08:37:40PM -0400, Greg Troxel wrote:
> "James K. Lowden" <jklowden@schemamania.org> writes:
>
> > One of these days, I'd like to do/see a presentation called "Journey of a
> > Keystroke" that walked through all the layers of mediation and
> > interpretation, and how they're controlled. I'd like to know why --
> > sooner or later, with enough indirection via ssh/rsh -- the backspace key
> > starts being echoed as ^H when I mistype a search in less(1).
>
> Basically:
>
> The IBM PC put a Backspace key where the DEL key ought to be, or maybe
> this is from IBM 3270 etc.
>
> To atone for their sins, they made BS act like DEL acted from V7 unix
> on (and also on DEC operating systems).
>
> There are two ways to cope with this (meaning the odd placement of BS,
> together with software like emacs that expects DEL):
>
> 1) Map Backspace to DEL, making the key do what the key that's there
> should. Don't change anything else, meaning stty erase ^?. This
> is my approach. In xterm, Control-Backspace is DEL normally, and
> if you set *ptyInitialErase to true, Control-Backspace is then ^H
> (with plain Backspace DEL).
That's how the PC (PS/2) keyboard work under wscons. USB keyboard is different
for some reason. (PR kern/32755, PR kern/32754 )
As the PC keyboard works fine as it is now, I propose to change the USB
keyboard mapping to match the PC keyboard. As you note below, doing it the
other way seems too complicated.
> 2) Leave Backspace as ^H, but then stty erase ^H. This sets up for
> a whole cascading kludge where many things are changed to cope
> with this:
>
> a) emacs has code (by experimentation) to remap characters if
> erase is ^H so that pushing the key where DEL ought to be does
> what you expect. It does this by remapping BS to DEL before the
> keymap sees it.
>
> In this mode, it's hard to get help. Even worse, some things (I
> can't remember anymore) don't get remapped properly.
>
> Hint: Don't try C-M-BS if you are running X. I have done that
> *twice* while experimenting and composing this message....
>
> b) When sshing to a remote system, and maybe telnet, propagate
> the value of stty erase. Logging in from NetBSD to NetBSD with
> OpenSSH does this. So the programs on the far side also remap ^H
> to DEL.
>
> If you log in to a remote system in a way that doesn't do this,
> you end up with a mess. This can happen with a serial port, or a
> non-NetBSD system.
>
>
> So, I'm in favor of fixing the problem once by fixing the keymap.
Pavel