irb and readline

L

listrecv

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

Phrogz

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).
 
L

listrecv

Phrogz said:
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?
 
P

Peña, Botp

From: (e-mail address removed) [mailto:[email protected]]=20
# 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,=20
# 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=3D"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"
=3D> "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
 
L

listrecv

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?
 
D

Dave Burt

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
 
L

listrecv

Dave said:
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)
 
S

Sean O'Halpin

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
 
P

Phrogz

Dave said:
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?
 
L

listrecv

Sean said:
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?
 
S

Sean O'Halpin

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
 
L

listrecv

Sean said:
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.
 
L

listrecv

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.)
 
D

Dave Burt

(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
 
D

Dave Burt

Phrogz said:
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
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top