Irb misbehaviour with arrow keys on Windows

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

On Sun, Nov 7, 2010 at 12:40 PM, Marvin Gülker [email protected] wrote:

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.


Phillip G.

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 G. 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

On Nov 7, 6:23pm, Marvin G. [email protected] wrote:

  1. Type “abcdef” and press return
  2. Press the up arrow key
  3. Press the down arrow key
  4. 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

On Nov 7, 8:40am, Marvin Gülker [email protected] wrote:

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.

Hi,

2010/11/7 Marvin Gülker [email protected]:

press return followed by the up arrow key, the whole sequence you typed,
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

Regards,
Park H.

On Nov 7, 10:19pm, Heesob P. [email protected] wrote:

Hi there,
including the mysteriously invisible characters, shows up.

  • when ‘X’

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.

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

On Sun, 7 Nov 2010 06:40:24 -0500, Marvin Gülker [email protected]
wrote in [email protected]:

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)

On Fri, 12 Nov 2010 17:40:35 -0500, Charles C. [email protected]
wrote in [email protected]:

On Sun, 7 Nov 2010 06:40:24 -0500, Marvin Gülker [email protected]
wrote in [email protected]:

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.