in reply to STDIN Odd Bevahior in Linux Environments

Is this related to perl at all? Or does the same happen when you just start cat, type a few characters and then hit backspace?

I guess the terminal is not configured as you'd like it to be.

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^2: STDIN Odd Bevahior in Linux Environments
by halfcountplus (Hermit) on Sep 24, 2009 at 01:13 UTC
    No, it isn't related to perl, but it is understandable that you don't know that.

    What it is related to is the terminal "emulator" you are using. They vary somewhat, as does the means of dealing with this issue. The reason is that the emulator can capture and modify various key codes.

    For example, I use the XFCE Terminal. If I go to Preferences->advanced, there is the option: "Backspace key generates" and the choices include Control-H, which is what you are getting (they also include "Escape sequence", which would be the normative ascii value of backspace, and ascii del, which would make backspace == delete).

    Probably you are using the gnome-terminal, but I think if you look around in it you will be able to find something similar. Most likely, your Ubuntu and your RedHat are configured differently. You may have more luck on a linux forum, many people there will understand perl and be more familiar with little OS details like this.

    MidLifeXis's suggestion is probably a good one, since the shell is intermediary between the terminal and perl.

      This is not just a terminal emulator issue.

      Terminal settings on Unix was designed at a time where terminals were hardware, so terminal settings must be set on the server side. Or at least unix side settings must match terminal side settings.

      You have two sets of settings on the unix side:

      • line settings defined with stty for the most important control keys (break, sleep, pause...)
      • TERM environment variable which tells all settings for curses applications that use it. This variable is the name of a file in /usr/share/terminfo

      If your TERM variable is correctly set to match your terminal emulator, you can use the terminfo settings to set the line settings in your profile:

      [[ -n "$TERM" ]] && stty erase "$(tput kbs)" susp "$(tput kspd)"
Re^2: STDIN Odd Bevahior in Linux Environments
by bichonfrise74 (Vicar) on Sep 23, 2009 at 22:14 UTC
    I think it might not be related to Perl but thought people might have seen this.

    Anyway, if I start cat and type a few characters and hit backspace, then it works fine on Ubuntu 8.04 (this is the OS where I'm having the backspace problem).