irb misbehaviour with arrow keys on Windows

Discussion in 'Ruby' started by Marvin Gülker, Nov 7, 2010.

  1. Hi there,

    It seems that irb has problems with the arrow keys on Windows. Steps to
    reproduce:

    1. Start up CMD.
    2. Type "irb" and press return
    3. Type "abc" and *do not* press return
    4. Press the right arrow key
    5. Now try typing "defg" - the characters don't show up anymore. If you
    press return followed by the up arrow key, the whole sequence you typed,
    including the mysteriously invisible characters, shows up.

    I'm using ruby 1.9.2p0 (2010-08-18) [i386-mingw32] on Windows Vista
    32-bit, installed by extracting the 7z archive provided by the
    RubyInstaller team to C:\Rubies\ruby-1.9.2-p0-i386-mingw32. Of course I
    added the bin\ subdirectory to my PATH variable.
    I don't know wheather in matters, but I don't have the RubyInstaller's
    devkit installed, but a separate MinGW+MSYS installation in C:\MinGW
    which is up-to-date.

    Anyone experiencing the same problem?

    Valete,
    Marvin

    --
    Posted via http://www.ruby-forum.com/.
    Marvin Gülker, Nov 7, 2010
    #1
    1. Advertising

  2. On Sun, Nov 7, 2010 at 12:40 PM, Marvin G=C3=BClker <> wrote=
    :
    > Hi there,
    >
    > It seems that irb has problems with the arrow keys on Windows. Steps to
    > reproduce:
    >
    > 1. Start up CMD.
    > 2. Type "irb" and press return
    > 3. Type "abc" and *do not* press return
    > 4. Press the right arrow key
    > 5. Now try typing "defg" - the characters don't show up anymore. If you
    > press return followed by the up arrow key, the whole sequence you typed,
    > including the mysteriously invisible characters, shows up.


    This also happens in PowerShell / Windows 7 Professional.

    Hitting enter after the above steps reveals that the "d" gets
    swallowed up, however, and only "abcefg" are being processed.

    --=20
    Phillip Gawlowski

    Though the folk I have met,
    (Ah, how soon!) they forget
    When I've moved on to some other place,
    There may be one or two,
    When I've played and passed through,
    Who'll remember my song or my face.
    Phillip Gawlowski, Nov 7, 2010
    #2
    1. Advertising

  3. Phillip Gawlowski wrote in post #959914:
    > Hitting enter after the above steps reveals that the "d" gets
    > swallowed up, however, and only "abcefg" are being processed.


    You're right, I didn't even notice that. What is even worse, is trying
    to use irb within the MSYS bash:

    1. Start up bash
    2. Type "irb" and press return
    3. Type "abcdef" and press return
    4. Press the up arrow key
    5. Press the down arrow key
    6. Press up again: Now you've got your previous line twice! You can
    repeat this process as often as you want, the line keeps getting longer
    and longer.

    (Hopefully these steps are correct, I just wrote them down from memory
    as I don't have access to the Vista machine for some time now).

    As a side note: I usually don't use CMD directly on Windows, because
    it's kind of difficult to manage all these shells in different windows
    (sometimes I run irb, MSYS bash, CMD and Cygwin bash simultanously).
    Therefore I'm using Console2, which may explains some odd input
    behaviour.

    Valete,
    Marvin

    --
    Posted via http://www.ruby-forum.com/.
    Marvin Gülker, Nov 7, 2010
    #3
  4. Marvin Gülker

    Luis Lavena Guest

    On Nov 7, 6:23 pm, Marvin Gülker <> wrote:
    > Phillip Gawlowski wrote in post #959914:
    >
    > > Hitting enter after the above steps reveals that the "d" gets
    > > swallowed up, however, and only "abcefg" are being processed.

    >
    > You're right, I didn't even notice that. What is even worse, is trying
    > to use irb within the MSYS bash:
    >
    > 1. Start up bash
    > 2. Type "irb" and press return
    > 3. Type "abcdef" and press return
    > 4. Press the up arrow key
    > 5. Press the down arrow key
    > 6. Press up again: Now you've got your previous line twice! You can
    > repeat this process as often as you want, the line keeps getting longer
    > and longer.
    >
    > (Hopefully these steps are correct, I just wrote them down from memory
    > as I don't have access to the Vista machine for some time now).
    >


    Unable to reproduce, Ruby 1.9.2-p0, 1.8.7-p302

    Windows 7, x64. using default command prompt (cmd.exe) or MSYS bash.

    > As a side note: I usually don't use CMD directly on Windows, because
    > it's kind of difficult to manage all these shells in different windows
    > (sometimes I run irb, MSYS bash, CMD and Cygwin bash simultanously).
    >
    > Therefore I'm using Console2, which may explains some odd input
    > behaviour.
    >


    I'm using it too and don't see the odd behavior you're describing.

    I'm using 2.00.146 version

    --
    Luis Lavena
    Luis Lavena, Nov 7, 2010
    #4
  5. Marvin Gülker

    Luis Lavena Guest

    On Nov 7, 8:40 am, Marvin Gülker <> wrote:
    > Hi there,
    >
    > It seems that irb has problems with the arrow keys on Windows. Steps to
    > reproduce:
    >
    > 1. Start up CMD.
    > 2. Type "irb" and press return
    > 3. Type "abc" and *do not* press return
    > 4. Press the right arrow key
    > 5. Now try typing "defg" - the characters don't show up anymore. If you
    > press return followed by the up arrow key, the whole sequence you typed,
    > including the mysteriously invisible characters, shows up.
    >
    > I'm using ruby 1.9.2p0 (2010-08-18) [i386-mingw32] on Windows Vista
    > 32-bit, installed by extracting the 7z archive provided by the
    > RubyInstaller team to C:\Rubies\ruby-1.9.2-p0-i386-mingw32. Of course I
    > added the bin\ subdirectory to my PATH variable.


    What codepage (chcp) are you using?

    I'm not been able to reproduce this, as responded to this thread
    already.

    > I don't know wheather in matters, but I don't have the RubyInstaller's
    > devkit installed, but a separate MinGW+MSYS installation in C:\MinGW
    > which is up-to-date.
    >


    Not unless you're running inside a bash terminal, but even that should
    not affect it.

    --
    Luis Lavena
    Luis Lavena, Nov 7, 2010
    #5
  6. Marvin Gülker

    Heesob Park Guest

    Hi,

    2010/11/7 Marvin G=C3=83=C2=BClker <>:
    > Hi there,
    >
    > It seems that irb has problems with the arrow keys on Windows. Steps to
    > reproduce:
    >
    > 1. Start up CMD.
    > 2. Type "irb" and press return
    > 3. Type "abc" and *do not* press return
    > 4. Press the right arrow key
    > 5. Now try typing "defg" - the characters don't show up anymore. If you
    > press return followed by the up arrow key, the whole sequence you typed,
    > including the mysteriously invisible characters, shows up.
    >
    > I'm using ruby 1.9.2p0 (2010-08-18) [i386-mingw32] on Windows Vista
    > 32-bit, installed by extracting the 7z archive provided by the
    > RubyInstaller team to C:\Rubies\ruby-1.9.2-p0-i386-mingw32. Of course I
    > added the bin\ subdirectory to my PATH variable.
    > I don't know wheather in matters, but I don't have the RubyInstaller's
    > devkit installed, but a separate MinGW+MSYS installation in C:\MinGW
    > which is up-to-date.
    >
    > Anyone experiencing the same problem?
    >

    This is a bug of rbreadline.

    Here is a patch for rbrealine.rb
    --- rbreadline.rb 2010-11-08 10:10:28.000000000 +0900
    +++ rbreadline.rb.new 2010-11-08 10:10:11.000000000 +0900
    @@ -8435,21 +8435,20 @@
    count -=3D 1
    end

    + str =3D (flags =3D=3D MB_FIND_NONZERO) ? string.strip : string
    +
    case @encoding
    when 'E'
    - point +=3D string[point..-1].scan(/./me)[0,count].to_s.length
    + point +=3D str[point..-1].scan(/./me)[0,count].to_s.length
    when 'S'
    - point +=3D string[point..-1].scan(/./ms)[0,count].to_s.length
    + point +=3D str[point..-1].scan(/./ms)[0,count].to_s.length
    when 'U'
    - point +=3D string[point..-1].scan(/./mu)[0,count].to_s.length
    + point +=3D str[point..-1].scan(/./mu)[0,count].to_s.length
    when 'X'
    - point +=3D string[point..-1].force_encoding(@encoding_name)[0,cou=
    nt].byt
    + point +=3D str[point..-1].force_encoding(@encoding_name)[0,count]=
    bytesi
    else
    point +=3D count
    end
    - if flags =3D=3D MB_FIND_NONZERO
    - point =3D string.length if point>=3Dstring.length
    - end
    point
    end


    Regards,
    Park Heesob
    Heesob Park, Nov 8, 2010
    #6
  7. Marvin Gülker

    Luis Lavena Guest

    On Nov 7, 10:19 pm, Heesob Park <> wrote:
    > Hi,
    >
    > 2010/11/7 Marvin Gülker <>:
    >
    >
    >
    >
    >
    >
    >
    > > Hi there,

    >
    > > It seems that irb has problems with the arrow keys on Windows. Steps to
    > > reproduce:

    >
    > > 1. Start up CMD.
    > > 2. Type "irb" and press return
    > > 3. Type "abc" and *do not* press return
    > > 4. Press the right arrow key
    > > 5. Now try typing "defg" - the characters don't show up anymore. If you
    > > press return followed by the up arrow key, the whole sequence you typed,
    > > including the mysteriously invisible characters, shows up.

    >
    > > I'm using ruby 1.9.2p0 (2010-08-18) [i386-mingw32] on Windows Vista
    > > 32-bit, installed by extracting the 7z archive provided by the
    > > RubyInstaller team to C:\Rubies\ruby-1.9.2-p0-i386-mingw32. Of course I
    > > added the bin\ subdirectory to my PATH variable.
    > > I don't know wheather in matters, but I don't have the RubyInstaller's
    > > devkit installed, but a separate MinGW+MSYS installation in C:\MinGW
    > > which is up-to-date.

    >
    > > Anyone experiencing the same problem?

    >
    > This is a bug of rbreadline.
    >
    > Here is a patch for rbrealine.rb
    > --- rbreadline.rb       2010-11-08 10:10:28.000000000 +0900
    > +++ rbreadline.rb.new   2010-11-08 10:10:11.000000000 +0900
    > @@ -8435,21 +8435,20 @@
    >           count -= 1
    >        end
    >
    > +      str = (flags == MB_FIND_NONZERO) ? string.strip : string
    > +
    >        case @encoding
    >        when 'E'
    > -         point += string[point..-1].scan(/./me)[0,count].to_s.length
    > +         point += str[point..-1].scan(/./me)[0,count].to_s.length
    >        when 'S'
    > -         point += string[point..-1].scan(/./ms)[0,count].to_s.length
    > +         point += str[point..-1].scan(/./ms)[0,count].to_s.length
    >        when 'U'
    > -         point += string[point..-1].scan(/./mu)[0,count].to_s.length
    > +         point += str[point..-1].scan(/./mu)[0,count].to_s.length
    >        when 'X'
    > -         point += string[point..-1].force_encoding(@encoding_name)[0,count].byt
    > +         point += str[point..-1].force_encoding(@encoding_name)[0,count]bytesi
    >        else
    >           point += count
    >        end
    > -      if flags == MB_FIND_NONZERO
    > -         point = string.length if point>=string.length
    > -      end
    >        point
    >     end
    >


    Park, if you believe so, please commit to rb-readline repository and
    document why this is happening.

    Is hard for me follow this as I'm not able to reproduce the bug and
    clearly you know better what is going on down the pipes.

    Thank you.
    --
    Luis Lavena
    Luis Lavena, Nov 8, 2010
    #7
  8. I'm sorry, but as I stated previously, I don't have access to a Windows
    machine for the moment (for the curious ones: It's my only one and the
    laptop it runs on had a serious problem with it's display, so it's away
    for repair now).

    As soon as I get my box back, I'll look up which codepage it uses.

    Vale,
    Marvin

    --
    Posted via http://www.ruby-forum.com/.
    Marvin Gülker, Nov 9, 2010
    #8
  9. On Sun, 7 Nov 2010 06:40:24 -0500, Marvin Gülker <>
    wrote in <>:

    >It seems that irb has problems with the arrow keys on Windows. Steps to
    >reproduce:
    >
    >1. Start up CMD.
    >2. Type "irb" and press return
    >3. Type "abc" and *do not* press return
    >4. Press the right arrow key
    >5. Now try typing "defg" - the characters don't show up anymore. If you
    >press return followed by the up arrow key, the whole sequence you typed,
    >including the mysteriously invisible characters, shows up.
    >
    >I'm using ruby 1.9.2p0 (2010-08-18) [i386-mingw32] on Windows Vista
    >32-bit, installed by extracting the 7z archive provided by the
    >RubyInstaller team to C:\Rubies\ruby-1.9.2-p0-i386-mingw32. Of course I
    >added the bin\ subdirectory to my PATH variable.
    >I don't know wheather in matters, but I don't have the RubyInstaller's
    >devkit installed, but a separate MinGW+MSYS installation in C:\MinGW
    >which is up-to-date.


    Datapoint: I'm unable to reproduce this.

    Environment:

    ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32] (installed using
    executable installer downloaded from RubyInstaller.org)
    Windows XP SP3, 32 bit
    default command shell (cmd.exe)

    --
    Charles Calvert | Software Design/Development
    Celtic Wolf, Inc. | Project Management
    http://www.celticwolf.com/ | Technical Writing
    (703) 580-0210 | Research
    Charles Calvert, Nov 12, 2010
    #9
  10. On Fri, 12 Nov 2010 17:40:35 -0500, Charles Calvert <>
    wrote in <>:

    >On Sun, 7 Nov 2010 06:40:24 -0500, Marvin Gülker <>
    >wrote in <>:


    >Datapoint: I'm unable to reproduce this.
    >
    >Environment:
    >
    >ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32] (installed using
    >executable installer downloaded from RubyInstaller.org)
    >Windows XP SP3, 32 bit
    >default command shell (cmd.exe)


    Note: couldn't reproduce it with Windows PowerShell either.

    --
    Charles Calvert | Software Design/Development
    Celtic Wolf, Inc. | Project Management
    http://www.celticwolf.com/ | Technical Writing
    (703) 580-0210 | Research
    Charles Calvert, Nov 13, 2010
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arian Sanusi
    Replies:
    0
    Views:
    449
    Arian Sanusi
    Jan 27, 2008
  2. Fredrik Lundh
    Replies:
    0
    Views:
    361
    Fredrik Lundh
    Jan 27, 2008
  3. Aníbal
    Replies:
    1
    Views:
    104
    Michael Glaesemann
    Nov 13, 2006
  4. Pokkai Dokkai
    Replies:
    6
    Views:
    116
    Joel VanderWerf
    Dec 24, 2007
  5. Rico
    Replies:
    0
    Views:
    170
Loading...

Share This Page