I'm working at a company that uses three different Unices (Linux, Solaris and AIX) all with the same home directories/etc. They all use GNU coreutils (thankfully!), but it's still "interesting" trying to work around various issues. We connect to them by running an X server (Exceed On Demand) on our (Windows) desktops and using xterm, or sshing from another machine from an existing xterm window (there are other methods too but I don't currently use them so I'll leave them out for now).

In particular, I had issues on Solaris with the backspace key. It would work in bash but just print ^H in some other applications (especially readline-based things).

I'm currently using the solution of having stty erase ^H in my ~/.profile and the following in my ~/.Xdefaults:

*VT100.Translations: #override \
              <Key>BackSpace: string(0x08)\n

This seems to work most of the time but is perhaps not desirable since I'm explicitly setting the backspace key to something that might not be the default/preferred on each platform. In particular, I often get messages when using reset reminding me that I've set erase to ^H, and very occasionally through a series of circumstances that I haven't yet been able to figure out everything breaks again; perhaps things will work in readline-based apps but not in bash; and I'll have to type reset to get everything back to normal.

These issues lead me to believe that this might not be the preferred way of doing this. Does anyone have any improvement over this situation?


Some applications are hardcoded to expect a given erase character, and there's not much you can do with those.

But addressing the comment

I'm more wondering if I should be doing something else to try to get the backspace sent my xterm to match the default backspace expected by the TTY device.

you could set the ptyInitialErase resource:

If "true", xterm will use the pseudo-terminal's sense of the stty erase value. If "false", xterm will set the stty erase value to match its own configuration, using the kb string from the termcap entry as a reference, if available. In either case, the result is applied to the TERMCAP variable which xterm sets.

See also the ttyModes resource, which may override this. The default is "False".

But for making xterm act consistently, ttyModes works. Keep in mind that changing stty only tells the system what to expect. You can change the behavior of the backarrow (backspace) key using the ackarrowKey resource:

Specifies whether the backarrow key transmits a backspace (8) or delete (127) character. This corresponds to the DECBKM control sequence. A "true" value specifies backspace. The default is "True". Pressing the control key toggles this behavior.

  • I set ptyInitialErase and got rid of all stty commands that I could find, but I still get issues on Solaris. I have no ttyModes or VT100.Translations in my .Xdefaults any more, and I don't think there are any stty commands left. The output of stty on Sun shows erase as ^?, but if I type cat (in order to use the system's line discipline), I get ^H appearing on my terminal when I press backspace.
    – Muzer
    Nov 11 '16 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.