Irb and readline

I’m getting funny behavior when using irb (readline) on Windows. When
I go back to a very long line in the history, I can’t edit it. After
hit the left arrow a few times, the cursors moves up a line, and not
left anymore. At that point, I can’t figure out what I’m typing, and
so I have to Ctrl-C.

Does anyone else experience this problem? More importantly, is there a
way to fix it?

Any ideas or help appreciated.

On 7/17/06, [email protected] [email protected] wrote:

I’m getting funny behavior when using irb (readline) on Windows. When
I go back to a very long line in the history, I can’t edit it. After
hit the left arrow a few times, the cursors moves up a line, and not
left anymore. At that point, I can’t figure out what I’m typing, and
so I have to Ctrl-C.

Does anyone else experience this problem? More importantly, is there a
way to fix it?

I see this myself, though I don’t know if I have ‘readline’ enabled.
It’s
really annoying.

[email protected] wrote:

I’m getting funny behavior when using irb (readline) on Windows. When
I go back to a very long line in the history, I can’t edit it.

Since you asked, yes, I experience this too. You’re not alone.

Unfortunately, I cannot answer your second question (how to fix this).

Phrogz wrote:

[email protected] wrote:

I’m getting funny behavior when using irb (readline) on Windows. When
I go back to a very long line in the history, I can’t edit it.

Since you asked, yes, I experience this too. You’re not alone.

Unfortunately, I cannot answer your second question (how to fix this).

What is the correct place to submit this as a bug report, then?

From: [email protected] [mailto:[email protected]]

I’m getting funny behavior when using irb (readline) on Windows. When

I go back to a very long line in the history, I can’t edit it. After

hit the left arrow a few times, the cursors moves up a line, and not

left anymore. At that point, I can’t figure out what I’m typing, and

so I have to Ctrl-C.

Does anyone else experience this problem? More importantly,

is there a

way to fix it?

Any ideas or help appreciated.

also experienced that, but when i upgraded to latest one-click, the odd
behavior disappeared.

irb(main):003:0> x=“athas dfjalsd thsi is a very long line of text
asd;fljas;dlf
jas;dlfja;sdlfjas ldjflakj djfkjdf
jdkfjsdkfjskdfjksdjf;alskdjflasdjflasjdflasdj
fa;lsdfjalsdkjf jdkfjdkjfkdjfdlksjfslkdjfslkdjfkdjf dkfjkdjfkdjfkd jfl
jflskdjfl
aksjdflasdkjflsk djfksjdf klsjdf;lakdsjf
sjdflkajsdflksjdflaskjflaskdjf;alsdkfja
;sldkfj;lsd fja;lsd ja;lfk a;ldfj asj;lsdfja;sdlfkj sldkfjslkjfsldjf
;slfjasldjf
a;sdl fasd;lfjs djflskdjf lsdkjf sldjfslkdjf lsf”
=> “athas dfjalsd thsi is a very long line of text
asd;fljas;dlfjas;dlfja;sdlfja
s ldjflakj djfkjdf
jdkfjsdkfjskdfjksdjf;alskdjflasdjflasjdflasdjfa;lsdfjalsdkjf
jdkfjdkjfkdjfdlksjfslkdjfslkdjfkdjf dkfjkdjfkdjfkd jfl
jflskdjflaksjdflasdkjflsk
djfksjdf klsjdf;lakdsjf
sjdflkajsdflksjdflaskjflaskdjf;alsdkfja;sldkfj;lsd fja;
lsd ja;lfk a;ldfj asj;lsdfja;sdlfkj sldkfjslkjfsldjf ;slfjasldjfa;sdl
fasd;lfjs
djflskdjf lsdkjf sldjfslkdjf lsf”
irb(main):004:0> quit

C:\Documents and Settings\botp>irb --version
irb 0.9.5(05/04/13)

C:\Documents and Settings\botp>ruby -v
ruby 1.8.4 (2006-04-14) [i386-mswin32]

not sure if this helps though.
kind regards -botp

I’m running exact same ruby/irb vers, and still get this. Not always -
I wasn’t able to figure out exactly when it happens.

Where can I report this bug?

Peña wrote:

[email protected] wrote:

I’m getting funny behavior when using irb (readline) on Windows. When
I go back to a very long line in the history, I can’t edit it. After
hit the left arrow a few times, the cursors moves up a line, and not
left anymore. At that point, I can’t figure out what I’m typing, and
so I have to Ctrl-C.

Does anyone else experience this problem? More importantly, is there a
way to fix it?

Any ideas or help appreciated.

On Windows, under the cmd.exe shell, you don’t need readline for
history, cmd.exe provides it by default. My preference is to run
irb --noreadline. As an added bonus, that means I can paste text with
tabs in it into the irb session.

Cheers,
Dave

Dave B. wrote:

On Windows, under the cmd.exe shell, you don’t need readline for
history, cmd.exe provides it by default. My preference is to run
irb --noreadline. As an added bonus, that means I can paste text with
tabs in it into the irb session.

Good tip. The only problem is that this breaks tab completion also,
which I find very helpful.

However, you may have found the cause of the bug. Perhaps the fact
that cmd.exe is providing its own history interferes with irb’s
readline history. Is there anyway to shut off cmd’s history?

(As an aside, I don’t think it’s possible to run a console program in
Windows without going through cmd.exe)

Dave B. wrote:

On Windows, under the cmd.exe shell, you don’t need readline for
history, cmd.exe provides it by default. My preference is to run
irb --noreadline.

Nice, that solves it for me, too.

Any .bat geeks able to tell me how to modify the irb.bat file that
comes with the one-click installer so that this option is always
specified?

On 7/19/06, [email protected] [email protected] wrote:

Is there anyway to shut off cmd’s history?
Doesn’t appear to be. It used to be “keys off” but on XP:

C:>keys /?
Enables or disables command line editing on DOS system

This is present for Compatibility with DOS systems. It has no effect
under Windows XP, as command line editing is always enabled.

(As an aside, I don’t think it’s possible to run a console program in
Windows without going through cmd.exe)

Not true. For example, try double-clicking on a .rb file in Explorer -
that runs ruby as a console program without going through cmd.exe.

Regards,
Sean

Sean O’Halpin wrote:

Not true. For example, try double-clicking on a .rb file in Explorer -
that runs ruby as a console program without going through cmd.exe.

I believe that there is still a cmd.exe running in the background,
powering it.

If I’m wrong, is there a way to make a .bat script invoke irb, but skip
cmd.exe?

On 7/19/06, Phrogz [email protected] wrote:

Any .bat geeks able to tell me how to modify the irb.bat file that
comes with the one-click installer so that this option is always
specified?

Replace the section at the top with (notice --noreadline added):

@echo off
if not “%~f0” == “~f0” goto WinNT
ruby -Sx “%0” %1 %2 %3 %4 %5 %6 %7 %8 %9 --noreadline
goto endofruby
:WinNT
“%~d0%~p0ruby” -x “%~f0” %* -r irb/completion --noreadline
goto endofruby

On 7/19/06, [email protected] [email protected] wrote:

Sean O’Halpin wrote:

Not true. For example, try double-clicking on a .rb file in Explorer -
that runs ruby as a console program without going through cmd.exe.

I believe that there is still a cmd.exe running in the background,
powering it.

Nope. It’s spawned directly. Make sure you don’t have cmd.exe running,
double-click a .rb file containing just the line
gets
to make sure it waits for input, check Task Manager and you’ll see
that there is no cmd.exe running.

If I’m wrong, is there a way to make a .bat script invoke irb, but skip
cmd.exe?

No - .bat (& .cmd) files are scripts that are interpreted by cmd.exe.
However, you could have an irb.rb file containing this (pinched from
irb.bat):

require “irb”

if FILE == $0
IRB.start(FILE)
else

check -e option

if /^-e$/ =~ $0
IRB.start(FILE)
else
IRB.setup(FILE)
end
end

which would bypass cmd.exe. However, command line history seems to be
built into the console these days (i.e. it’s nothing to do with
cmd.exe).

Regards,
Sean

Sean O’Halpin wrote:

On 7/19/06, [email protected] [email protected] wrote:
Nope. It’s spawned directly. Make sure you don’t have cmd.exe running,
double-click a .rb file containing just the line
gets
to make sure it waits for input, check Task Manager and you’ll see
that there is no cmd.exe running.

However, command line history seems to be
built into the console these days (i.e. it’s nothing to do with
cmd.exe).

Got it. So, is there anyway to shut off history from the windows
console? That would probably solve the large-line-bug while still
allowing tab completion.

[email protected] wrote:

Got it. So, is there anyway to shut off history from the windows
console? That would probably solve the large-line-bug while still
allowing tab completion.

I was able to lower buffer size and number of buffers to 1, but it
didn’t solve the problem. (The console did keep a 1 line history,
though, so this still might be the problem.)

[email protected] wrote:

(As an aside, I don’t think it’s possible to run a console program in
Windows without going through cmd.exe)

You can use the old command.com shell (Windows XP still includes it)
instead of cmd.exe. I’m not sure what effect this would have.

Cheers,
Dave

Phrogz wrote:

Dave B. wrote:

On Windows, under the cmd.exe shell, you don’t need readline for
history, cmd.exe provides it by default. My preference is to run
irb --noreadline.

Nice, that solves it for me, too.

Any .bat geeks able to tell me how to modify the irb.bat file that
comes with the one-click installer so that this option is always
specified?

You can either add the --noreadline parameter to the ruby calls at the
top of irb.bat like so:

@echo off
if not “%~f0” == “~f0” goto WinNT
ruby -Sx “%0” --noreadline %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofruby
:WinNT
“%~d0%~p0ruby” -x “%~f0” --noreadline %*
goto endofruby

or you can insert it into ARGV in the Ruby section:


require “irb”
ARGV.unshift “–noreadline”

My favourite feature of disabling readline is that you can right-click
on the console window to access the Mark, Copy and Paste operations.

Cheers,
Dave

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs