Bug 6358

Summary: Xterm sets erase wrongly on tty
Product: [Retired] Red Hat Linux Reporter: erik
Component: xterm-colorAssignee: Preston Brown <pbrown>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: jbj, notting, redhat
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
URL: http://home.worldonline.dk/~ehcorry/linux/xterm-backspace.patch
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-01-18 20:12:50 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description erik 1999-10-25 23:56:51 UTC
Xterm reads its termcap entry in order to set stty erase to
the correct value.  The correct value is 'stty erase ^H'
since that is what xterm by default produces for a BackSpace
keysym, and that is what the termcap/terminfo entries say
(kb/kbs).  Unfortunately, xterm reads the wrong termcap
entry (kD equivalent to terminfo entry kdch1) and sets the
tty erase character to ^?.  This means programs that don't
autocompensate (cat, ftp, anything not linked to readline)
get confused and you can't delete with the expected button.
And programs that use readline lose the ability to delete to
the right (delete the character under the cursor) which is
the real meaning of kdch1 as per the terminfo docs (and what
any new user would expect).  This could otherwise be
achieved with a line
DEL: delete-char
in /etc/inputrc.

I linked to a patch that fixes it.  According to the xterm
FAQ on http://www.clark.net/pub/dickey/xterm/xterm.faq.html
this is the way it was originally, don't know who broke it,
but they didn't read the kD entry on man 5 termcap first.

An additional problem is that the xterm termcap entry would
be over 1023 characters, so it is truncated when converting
from terminfo.  This means that the kD (kdch1) info is
missing (doubly ironic when xterm tries wrongly to read it
to set the tty), so xterm does not know how to send the data
from the Delete key.  Xterm sends ^?, while apps that read
terminfo will expect ^[[3~ like on the linux console.  This
is a smaller problem since the line above will fix things
for readline apps that make up the majority of apps that
would know what to do with the delete key anyway.

Comment 1 erik 1999-10-26 09:23:59 UTC
I forgot to mention, you have to reverse the 'aaargh' patch to the
latest termcap (2.0.8-18) before xterm can see the termcap entry at
all.  The aaargh patch breaks the API.  Probably should be redone so
it works the old way unless the TERMCAP entry is overlong.  Not sure
what it was supposed to fix, anyway.

Comment 2 Bill Nottingham 1999-10-26 15:11:59 UTC
It's a security fix; it will most likely *not* be reverted.

Comment 3 Preston Brown 2000-01-18 20:12:59 UTC
xterm terminfo stuff fixed for next release.