Backspace in 12.0 script - Slackware

This is a discussion on Backspace in 12.0 script - Slackware ; Hello, friends, I'm adjusting still to Slackware 12.0. For example, I'm finally using the generic kernel instead of the huge one, but... One thing about 12.0 has me stymied. I ran a test. This doesn't happen in my Slackware 10.2 ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Backspace in 12.0 script

  1. Backspace in 12.0 script

    Hello, friends,

    I'm adjusting still to Slackware 12.0. For example, I'm finally using
    the generic kernel instead of the huge one, but...

    One thing about 12.0 has me stymied. I ran a test. This doesn't
    happen in my Slackware 10.2 installation:

    1. Make this script:

    #!/bin/sh
    #try

    echo say something
    read answer
    echo $answer

    2. chmod u+x try

    3. ./try

    4. Try will ask you to "say something". So type a few characters.
    Then try to use the backspace key before you press enter. If you
    are running in xterm in X (I tried fvwm2 and twm), then pressing the
    backspace key produces "^H" instead of actually doing a backspace.

    In Slackware 10.2 the same test actually *does* the backspace which is
    what I want. What good is it to get "^H" instead of *doing* the
    backspace?

    Note that when not in X both 10.2 and 12.0 *do* the backspace, so this
    seems to be related to X.

    Can anyone help me with this? I tried tinkering with xmodmap and
    ..screenrc, and I found this article on the web:

    http://www.cs.brown.edu/people/dnr/t...e-solution.txt

    But I haven't solved the problem yet. I just want backspace to *do*
    the backspace *all* the time whether I'm in X or not.

    Oh bother. I just solved the problem. I read the article I referenced
    above thinking "Man, I better read this."

    Well, the answer is use

    stty erase `tput kbs`

    at the command line in xterm first and all uses of script try will
    function in the desired way (with real backspace).

    I'm still troubled, though. Why the change (from 10.2 to 12.0) so that
    *now* "stty erase `tput kbs`" is needed to get the desired behavior?

    I'll quit now before I reveal any more foolishness.

    -Joe

  2. Re: Backspace in 12.0 script

    Joseph Rosevear wrote:
    > Hello, friends,
    >
    > I'm adjusting still to Slackware 12.0. For example, I'm finally using
    > the generic kernel instead of the huge one, but...
    >
    > One thing about 12.0 has me stymied. I ran a test. This doesn't
    > happen in my Slackware 10.2 installation:
    >
    > 1. Make this script:
    >
    > #!/bin/sh
    > #try
    >
    > echo say something
    > read answer
    > echo $answer
    >
    > 2. chmod u+x try
    >
    > 3. ./try
    >
    > 4. Try will ask you to "say something". So type a few characters.
    > Then try to use the backspace key before you press enter. If you
    > are running in xterm in X (I tried fvwm2 and twm), then pressing the
    > backspace key produces "^H" instead of actually doing a backspace.
    >
    > In Slackware 10.2 the same test actually *does* the backspace which is
    > what I want. What good is it to get "^H" instead of *doing* the
    > backspace?
    >
    > Note that when not in X both 10.2 and 12.0 *do* the backspace, so this
    > seems to be related to X.
    >
    > Can anyone help me with this? I tried tinkering with xmodmap and
    > .screenrc, and I found this article on the web:
    >
    > http://www.cs.brown.edu/people/dnr/t...e-solution.txt
    >
    > But I haven't solved the problem yet. I just want backspace to *do*
    > the backspace *all* the time whether I'm in X or not.
    >
    > Oh bother. I just solved the problem. I read the article I referenced
    > above thinking "Man, I better read this."
    >
    > Well, the answer is use
    >
    > stty erase `tput kbs`
    >
    > at the command line in xterm first and all uses of script try will
    > function in the desired way (with real backspace).
    >
    > I'm still troubled, though. Why the change (from 10.2 to 12.0) so that
    > *now* "stty erase `tput kbs`" is needed to get the desired behavior?
    >
    > I'll quit now before I reveal any more foolishness.
    >
    > -Joe


    It works with me these X resources:

    XTerm.ttyModes: erase ^?
    XTerm.vt100.backarrowKey: false

    In a bash script you couls also
    read -e answer

    this way you could use all the functionality of readline (cursor keys,
    history, etc.)

    Olive


  3. Re: Backspace in 12.0 script

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    On 2008-02-20, Joseph Rosevear wrote:
    > read answer
    > echo $answer
    > 4. Try will ask you to "say something". So type a few characters.
    > Then try to use the backspace key before you press enter. If you
    > are running in xterm in X (I tried fvwm2 and twm), then pressing the
    > backspace key produces "^H" instead of actually doing a backspace.


    This is entirely a terminal emulation problem.

    > In Slackware 10.2 the same test actually *does* the backspace which is
    > what I want. What good is it to get "^H" instead of *doing* the
    > backspace?


    In many terminal types, the backspace key sends a CONTOL-H (or
    abbreviated, ^H) to terminate the previous character. If you try it,
    you may find that works in place of backspace within a lot of apps.[0]

    > Note that when not in X both 10.2 and 12.0 *do* the backspace, so this
    > seems to be related to X.


    Your guess is a good one, but unfortunately incorrect. The terminal
    emulation used in the console and in xterm is quite different. These
    differences are contained in the terminfo database (found in
    /usr/share/terminfo).

    > Oh bother. I just solved the problem. I read the article I referenced
    > above thinking "Man, I better read this."
    >
    > Well, the answer is use
    >
    > stty erase `tput kbs`
    >
    > at the command line in xterm first and all uses of script try will
    > function in the desired way (with real backspace).


    You can put this in your .bashrc to handle it for you.

    if [ "$TERM" = "xterm" ]; then
    stty erase $(tput kbs)
    fi

    > I'm still troubled, though. Why the change (from 10.2 to 12.0) so that
    > *now* "stty erase `tput kbs`" is needed to get the desired behavior?


    Probably wasn't intentional. Has to be a change in the terminfo
    database. I don't have the ncurses source for 10.2 handy, but I
    noticed that between 10.1 and 12.0 an xterm.terminfo seemingly
    customized for Slackware has been added in source/l/ncurses. If some
    one can verify that this is the culprit, Pat might be willing to accept
    a patch to it.

    > I'll quit now before I reveal any more foolishness.


    On the contrary! It's a good question.

    [0] Similarly, ^W backspaces over the last word. What constitutes a
    word varies depending on the application. Sometimes only whitespace
    constitutes the begining and ending of a word; other times,
    non-alphanumeric characters are not considered to be parts of a word.

    - --
    It is better to hear the rebuke of the wise,
    Than for a man to hear the song of fools.
    Ecclesiastes 7:5
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.7 (GNU/Linux)

    iD8DBQFHvJO6rZS6hX/gvjoRAsgOAKDbUTEX3ZOxvGttsoB1q/W6yTlf9ACcCkUX
    N77gmI0bKSoN1Hecgdn6uWA=
    =gOgK
    -----END PGP SIGNATURE-----

  4. Re: Backspace in 12.0 script

    +Alan Hicks+ wrote:

    [snip]

    > This is entirely a terminal emulation problem.


    I don't know much about terminal emulation, but thanks.

    [snip]

    > In many terminal types, the backspace key sends a CONTOL-H (or
    > abbreviated, ^H) to terminate the previous character. If you try it,
    > you may find that works in place of backspace within a lot of apps.[0]


    Hmmm. My try script gives the same result in xterm for "^H" and
    . Without "stty erase `tput kbs`" both print "^H" to the
    screen. With "stty erase `tput kbs`" both do a backspace. Is this
    behavior an example of what you just described?

    However, when not in X (when at the console) "^H" doesn't give the same
    result as .

    I'm trying to understand. Seems like...

    vvv
    ....there are different levels to this problem. The backspace key and ^H
    are two different "key strokes" that have (probably) two different
    "codes" associated (mapped). I understand I can change that mapping
    (in X) by using

    xmodmap -e "keycode blah = something"

    where blah is the number of the key and something is the symbol for the
    "code".

    This "code" then can be interpreted in different ways depending on the
    terminal emulation. The terminal emulation begins with terminfo, but
    can be changed with the stty command.
    ^^^

    Did I get that right?

    > > Note that when not in X both 10.2 and 12.0 *do* the backspace, so this
    > > seems to be related to X.


    > Your guess is a good one, but unfortunately incorrect. The terminal
    > emulation used in the console and in xterm is quite different. These
    > differences are contained in the terminfo database (found in
    > /usr/share/terminfo).


    So, it is not exactly related to X, rather it is related to using xterm
    instead of the console?

    [snip]

    > You can put this in your .bashrc to handle it for you.


    > if [ "$TERM" = "xterm" ]; then
    > stty erase $(tput kbs)
    > fi


    Thanks. I did it. Works fine in xterm in 12.0

    > > I'm still troubled, though. Why the change (from 10.2 to 12.0) so that
    > > *now* "stty erase `tput kbs`" is needed to get the desired behavior?


    > Probably wasn't intentional. Has to be a change in the terminfo
    > database. I don't have the ncurses source for 10.2 handy, but I
    > noticed that between 10.1 and 12.0 an xterm.terminfo seemingly
    > customized for Slackware has been added in source/l/ncurses. If some
    > one can verify that this is the culprit, Pat might be willing to accept
    > a patch to it.


    Good idea. The crooked way should sometimes be made straight.

    [snip]

    > [0] Similarly, ^W backspaces over the last word. What constitutes a
    > word varies depending on the application. Sometimes only whitespace
    > constitutes the begining and ending of a word; other times,
    > non-alphanumeric characters are not considered to be parts of a word.


    Interesting.

    [skip]

    Thanks for you inputs.

    -Joe

  5. Re: Backspace in 12.0 script

    >> This is entirely a terminal emulation problem.
    >
    > I don't know much about terminal emulation, but thanks.


    Some term progams can be fixed by setting them to send "delete" instead of
    "backspace" (ctrl H). I have a term program I use all the time and the
    default sh on solaris works fine if I change this VT option.

    It all depends on how your term program works.

+ Reply to Thread