Bug or Feature? The behavior of "stty"
Get backspace working in a mixed environment often involves
stty erase ^? (or
stty erase ^h). However, today I found that sometimes they work sometimes they
do not work. This seemed a bug to me at first. But, after more tests, I found it
might be not a bug but a feature.
Here is the summary of the behavior of
stty erase on redhat linux.
- Whatever you set in your profile (default is "^?"), both "^h" and "^?" are regarded as <erase>.
stty erasecommand takes effect only when it really changes the <erase>.
For example, if you
stty erase ^hin your profile, running
stty erase ^hagain in command line does nothing and both "^h" and "^?" still work as <erase>. But, running
stty erase ^?will instantly make "^?" the only erase character.
So, when you find
stty erase ^? does not work as expected, run
stty erase ^h
first and then retry
stty erase ^?.
This behavior might be a nice feature. While still keeps the ability to modify the settings of <erase>, it makes both "^h" and "^?" work as <erase> even if you "inherit" a profile which set <erase> explicitly, which is very beginner-friendly.
blog comments powered by Disqus