Force IRB into interactive mode (to display prompt)?

I’m implementing a front end for irb that involves running it in a
background process. I have it working such that I can collect input
from my program and write it to the redirected stdin of irb and then
read the output from redirected stdout, but it looks like when irb
detects that it isn’t running in interactive mode it doesn’t print a
prompt for some reason.

I’ve tried setting conf.verbose = true, but that doesn’t work. If I
don’t redirect stdin, the prompt appears just fine. How can I force irb
to display the prompt, even if stdin is redirected?

I’m using 1.8.5 on windows xp.

On Oct 4, 2007, at 9:31 AM, Rob P. wrote:

to display the prompt, even if stdin is redirected?

I’m using 1.8.5 on windows xp.

Posted via http://www.ruby-forum.com/.

What are you trying to do?
You want some kind of status program to monitor activity?

John J. wrote:

On Oct 4, 2007, at 9:31 AM, Rob P. wrote:

to display the prompt, even if stdin is redirected?

I’m using 1.8.5 on windows xp.

Posted via http://www.ruby-forum.com/.

What are you trying to do?
You want some kind of status program to monitor activity?

I want to have a pane in my GUI that works like irb. Basically embed it
into a windows app. I’m starting a process in the background for irb
and I want to pass input to it and read output from it. It’s
interactive, it’s just indirectly interactive so irb doesn’t print the
prompt and dies immediately on error instead of printing the message and
staying alive.

2007/10/4, Rob P. [email protected]:

I want to have a pane in my GUI that works like irb. Basically embed it
into a windows app. I’m starting a process in the background for irb
and I want to pass input to it and read output from it. It’s
interactive, it’s just indirectly interactive so irb doesn’t print the
prompt and dies immediately on error instead of printing the message and
staying alive.

Rob, you could look at fxri (http://rubyforge.org/projects/fxri) how
they do it. It’s a part of the one-click-installer.

Regards,
Pit

Rob P. wrote:

I’m implementing a front end for irb that involves running it in a
background process. I have it working such that I can collect input
from my program and write it to the redirected stdin of irb and then
read the output from redirected stdout, but it looks like when irb
detects that it isn’t running in interactive mode it doesn’t print a
prompt for some reason.

I’ve tried setting conf.verbose = true, but that doesn’t work. If I
don’t redirect stdin, the prompt appears just fine. How can I force irb
to display the prompt, even if stdin is redirected?

I’m using 1.8.5 on windows xp.

May have solved my own problem.

It looks like passing:
–readline --prompt default

to irb makes things work. When I start irb normally, I end up with
readline for input and the prompt. When my app was starting the
process, I ended up with the stdio input and no prompt.

Thanks for all the replies.

Pit C. wrote:

2007/10/4, Rob P. [email protected]:

I want to have a pane in my GUI that works like irb. Basically embed it
into a windows app. I’m starting a process in the background for irb
and I want to pass input to it and read output from it. It’s
interactive, it’s just indirectly interactive so irb doesn’t print the
prompt and dies immediately on error instead of printing the message and
staying alive.

Rob, you could look at fxri (http://rubyforge.org/projects/fxri) how
they do it. It’s a part of the one-click-installer.

Regards,
Pit

I’ve looked at fxri and its UI is launched from the same ruby process
that is already running, so it can manipulate the IRB class directly.
FXRI has its own custom IRB Inputmethod and manages the printing of the
prompt itself. For various reasons I need to start the ruby process
separately from my main app (which isn’t in ruby). I could probably
write some ruby code that I executed instead of just running IRB that
managed the input and prompting, but I was hoping there was an easier
way that just involved setting some flags for IRB or something so it
behaved like it was in interactive mode.

Thanks.

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