Red Hat Bugzilla – Bug 91357
bashrc breaks stty erase
Last modified: 2014-03-16 22:36:22 EDT
# I'm seeing this wrongly reset stty erase to ^H when it was ^? and the terminal
# was sending ^? too. Disabling this fixes the problem -- merlin
# if [ -x /usr/bin/tput ]; then
# if [ "x`tput kbs`" != "x" ]; then # We can't do this with "dumb" terminal
# stty erase `tput kbs`
# elif [ -x /usr/bin/wc ]; then
# if [ "`tput kbs|wc -c `" -gt 0 ]; then # We can't do this with "dumb"
# stty erase `tput kbs`
This code would break erase inside screen for some users, or for me when I
logged in remotely.
tput kbs returned ^H when in all cases backspace generated ^?
I'm really not sure what cases the code is supposed to help with, but backspace
mapped to ^H is a thing of the past, you should concentrate on making sure that
all apps generate ^?, and leave things alone.
(it pains me when users ask me why backspace is _still_ broken in linux when
we've had more than 10 years to fix it)
If I'm missing something, let me know
I found that the problem is mostly because you have a nonstandard screenrc which
generates ^H instead of ^?, and you try to account for that.
IMO, this is the wrong way to do it, if that's the only reason you have the
You use this:
# This makes screen treat backspaces '^?' as
# deletes. There should be a fix in the code
# for the way termcap inheritance works,
# but I dont know where to put it, and this works.
bindkey -d -k kb stuff "\010"
Debian, and most other folks use that:
bindkey -k kb stuff "\177"
The second way is consistent and generates ^?.
Your way works for screen run on the local machine, but if I run screen on a
remote machine (not running RH), screen generates ^? (as it should), and your
bashrc code changes stty erase to ^H, causing backspace not to work.
Unless I missed something, I don't see why you're trying to support BS set to ^H
when it's been abandonned in all of linux years ago.
As it turns out, neither are correct.
Distributions, in general, should not change the default backspace key binding
in /etc/screenrc. Additionally, Screen ships with the backspace key defined as
'^H' in its termcap and terminfo settings; Debian modifies these to '^?'. I am
not sure if this might also be causing problems for you (and others) or not.
I'll look into fixing screen as it ships with Red Hat Linux, but I consider it
unlikely that this will fix compatibility problems with other distributions
which ship with broken default settings.
Packages which do not have the 'bindkey' entry in /etc/screenrc are (or will be)
in rawhide shortly, and are also available from the URLs below.
The above packages will *not* fix inter-operating system conflicts caused by
modified terminfo/termcap entries.
Unfortunately, I still have reports that removing this bindkey line breaks some
configurations, (though I have been unable to reproduce it myself). Thus, I
will re-break screen for the time-being, and work on this after my vacation.
You meight want to read http://www.ibb.net/~anne/keyboard.html
The Debian Policy states that BS must send ^?, that is why ther terminfo entry
If BS sends ^H, then C-h (as used eg. by Emacs) is not distinguishable from BS
and it is difficult to explain users, why BS generates help, etc.
I just don't understand why you are going through all that trouble to deal with
the fact that screen ships with a broken default of setting BS to ^H
Everyone else fixes this by doing the following:
in /etc/screenrc: bindkey -k kb stuff "\177"
in /etc/bashrc: don't muck with tput, just leave stty erase to ^?
The current RH config (BS=^H in screen but ^? everywhere else) is not only
complex, makes no sense to me, and doesn't work with escreen on a RH 9 machine
to another RH 9 machine.
Doing the above does fix the problem, and that's what other distros do AFAIK
There is light at the end of the tunnel on this 3-year-old issue; screen-4.0.1.
I've packaged it up and placed it on my web page. You can point 'yum' at:
or just download the packages directly:
Once you install this package, you need to comment out the 'stty erase `tput
kbs`' from /etc/bashrc and /etc/zshrc. Screen should work as it did previously
on Red Hat Linux, Red Hat Enterprise Linux, and Fedora Core - except that the
backspace key is handled by the parent terminal's settings and inherited by
Screen (the way it's supposed to work).
NOTE: This is not an official package; I want to get it out there for testing.
If it tests out well, I'll work with the shell maintainers to have the 'stty'
hack removed (if applicable) - which would then cause this bug to [finally] be
New (Fedora) package - screen-4.0.1-2.i386.rpm will appear in rawhide
soon. This package does *not* have a bindkey default, as per the
screen maintainer's recommendation. For now, you can retrieve the
proper RPMs using yum from my repository:
** Note: You will need to comment out the block which executes "stty
`tput kbs`" in /etc/bashrc if you are using setup <= 2.5.27-1.1
Changing component to "setup" (which owns /etc/bashrc)
Added in 2.5.28-1, will be in rawhide tomorrow.