irb misbehaviour with arrow keys on Windows

  • Thread starter Marvin Gülker
  • Start date
M

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?

Valete,
Marvin
 
P

Phillip Gawlowski

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

Marvin Gülker

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
 
L

Luis Lavena

Phillip Gawlowski wrote in post #959914:


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
 
L

Luis Lavena

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

Heesob Park

Hi,

2010/11/7 Marvin G=C3=83=C2=BClker said:
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
 
L

Luis Lavena

Hi,

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






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

Marvin Gülker

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
 
C

Charles Calvert

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)
 
C

Charles Calvert

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top