[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

irb shell exit

Scott Harper

9/17/2008 3:27:00 PM

I am totally new to programming so this may sound stupid, but I would
appreciate help.

I am following along in the the Simply Rails 2 book and I am entering
classes etc. into the irb shell in the ruby console window. The problem
I am having is that sometimes I enter the wrong command and I can't
figure out how to exit the irb shell. I have tried typing "exit" and
that works sometimes, but sometimes it doesn't. The issue arose once
after I hit the Tab key and the other time i don't think i pressed
anything out of the ordinary.

Please see screenshot for clarification.

Can someone please help?

Thanks!

Attachments:
http://www.ruby-...attachment/2706/irb_shel...

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

5 Answers

Nathan Powell

9/17/2008 3:36:00 PM

0

On Thu, Sep 18, 2008 at 12:27:07AM +0900, Scott Harper wrote:
> I am totally new to programming so this may sound stupid, but I would
> appreciate help.
>
> I am following along in the the Simply Rails 2 book and I am entering
> classes etc. into the irb shell in the ruby console window. The problem
> I am having is that sometimes I enter the wrong command and I can't
> figure out how to exit the irb shell. I have tried typing "exit" and
> that works sometimes, but sometimes it doesn't. The issue arose once
> after I hit the Tab key and the other time i don't think i pressed
> anything out of the ordinary.
>
> Please see screenshot for clarification.

It looks like you typed irb twice. Once to get into the shell, and once while in the
shell. I see though that you are using windows, and I have no idea how
irb works on there, but I would have thought it was similar.

npowell@delilah ~ $ irb
>> irb
>> exit
=> #<IRB::Irb: @context=#<IRB::Context:0xb7a2d840>,
@signal_status=:IN_EVAL, @scanner=#<RubyLex:0xb7a2d4a8>>
>> exit
npowell@delilah ~ $





>
> Can someone please help?
>
> Thanks!
>
> Attachments:
> http://www.ruby-...attachment/2706/irb_shel...
>
> --
> Posted via http://www.ruby-....
>

--
nathan
nathan_at_nathanpowell_dot_org

Another flaw in the human character is that everybody wants to build
and nobody wants to do maintenance.
~ Kurt Vonnegut
------------------------------------

Clinton D. Judy

9/17/2008 4:00:00 PM

0

Sometimes I open a parentheses without closing it, or a DO without an
END, or a { without a }... Once you get the hang of Ruby's pretty loose
syntax, you'll also realize you forgot to close something. That's not
what you did in the screenshot, but I'm warning you for next time. ;-) I
forget to do that all the time.

If all else fails, I hit CTRL+C, but I don't know if that causes
problems. Someone have a better understanding?

-----Original Message-----
From: Nathan Powell [mailto:nathan@nathanpowell.org]=20
Sent: Wednesday, September 17, 2008 11:36 AM
To: ruby-talk ML
Subject: Re: irb shell exit

On Thu, Sep 18, 2008 at 12:27:07AM +0900, Scott Harper wrote:
> I am totally new to programming so this may sound stupid, but I would
> appreciate help.
>=20
> I am following along in the the Simply Rails 2 book and I am entering
> classes etc. into the irb shell in the ruby console window. The
problem
> I am having is that sometimes I enter the wrong command and I can't
> figure out how to exit the irb shell. I have tried typing "exit" and
> that works sometimes, but sometimes it doesn't. The issue arose once
> after I hit the Tab key and the other time i don't think i pressed
> anything out of the ordinary.
>=20
> Please see screenshot for clarification.

It looks like you typed irb twice. Once to get into the shell, and once
while in the
shell. I see though that you are using windows, and I have no idea how
irb works on there, but I would have thought it was similar.

npowell@delilah ~ $ irb=20
>> irb
>> exit
=3D> #<IRB::Irb: @context=3D#<IRB::Context:0xb7a2d840>,
@signal_status=3D:IN_EVAL, @scanner=3D#<RubyLex:0xb7a2d4a8>>
>> exit
npowell@delilah ~ $=20





>=20
> Can someone please help?
>=20
> Thanks!
>=20
> Attachments:
> http://www.ruby-...attachment/2706/irb_shel...
>=20
> --=20
> Posted via http://www.ruby-....
>=20

--=20
nathan
nathan_at_nathanpowell_dot_org

Another flaw in the human character is that everybody wants to build
and nobody wants to do maintenance.
~ Kurt Vonnegut
------------------------------------



TPReal

9/17/2008 4:10:00 PM

0

Clinton D. Judy wrote:
> Sometimes I open a parentheses without closing it, or a DO without an
> END, or a { without a }... Once you get the hang of Ruby's pretty loose
> syntax, you'll also realize you forgot to close something. That's not
> what you did in the screenshot, but I'm warning you for next time. ;-) I
> forget to do that all the time.
>
> If all else fails, I hit CTRL+C, but I don't know if that causes
> problems. Someone have a better understanding?

Your exit is not really executed, because as you see, you are without
some nesting (the 3 in 009:3> tells you you're in sine three things,
like three classes or methods or something). You must first go out of
all things you're in by typing end in each line (or closing brackets).
Usually when you do a mistake, just type end and press enter until you
see the prompt ends with NNN:0> again (there might be some error message
too, just ignore it), and then your exit or anything else will work.

But for testing, just write a separate program! You won't have to repeat
everything in case of a mistake every time. Here is something about
writing separate programs:
http://al2o3-cr.blogspot.com/2008/08/second...

TPR.
--
Posted via http://www.ruby-....

Scott Harper

9/17/2008 4:21:00 PM

0

Thomas B. wrote:
> Clinton D. Judy wrote:
>> Sometimes I open a parentheses without closing it, or a DO without an
>> END, or a { without a }... Once you get the hang of Ruby's pretty loose
>> syntax, you'll also realize you forgot to close something. That's not
>> what you did in the screenshot, but I'm warning you for next time. ;-) I
>> forget to do that all the time.
>>
>> If all else fails, I hit CTRL+C, but I don't know if that causes
>> problems. Someone have a better understanding?
>
> Your exit is not really executed, because as you see, you are without
> some nesting (the 3 in 009:3> tells you you're in sine three things,
> like three classes or methods or something). You must first go out of
> all things you're in by typing end in each line (or closing brackets).
> Usually when you do a mistake, just type end and press enter until you
> see the prompt ends with NNN:0> again (there might be some error message
> too, just ignore it), and then your exit or anything else will work.
>
> But for testing, just write a separate program! You won't have to repeat
> everything in case of a mistake every time. Here is something about
> writing separate programs:
> http://al2o3-cr.blogspot.com/2008/08/second...
>
> TPR.

The problem was that I didn't type end. I feel very stupid now. Thanks
for the help all!

Also found that CTRL+D works. Is this a coincidence that CTRL+C and
CTRL+D both work?

Cheers!

Scott
--
Posted via http://www.ruby-....

Henning Bekel

9/17/2008 4:40:00 PM

0

Scott Harper wrote:

> I am following along in the the Simply Rails 2 book and I am entering
> classes etc. into the irb shell in the ruby console window. The
> problem I am having is that sometimes I enter the wrong command and I
> can't figure out how to exit the irb shell. I have tried typing "exit"
> and that works sometimes, but sometimes it doesn't. The issue arose
> once after I hit the Tab key and the other time i don't think i
> pressed anything out of the ordinary.
>
> Please see screenshot for clarification.
>
> Can someone please help?
>
> Thanks!
>
> Attachments:
> http://www.ruby-forum.com/attachment/2706/irb_shel...

Note that "exit" is just another ruby function that simply exits the
running program (irb in this case) rather than something like an irb
"metacommand".

It seems that apart from typing irb twice in your session you forgot to
close your function and class definitions with "end", thus ruby is
still waiting for you to finish them before the definition (and any
exit call *outside* of a function definition) gets evaluated as a
whole. An exit call inside a method definition of a class will only be
evaluated if that method is actually being called.

So, if you need to bail out of irb, either call exit while not being
inside a class or method def, or hit CTRL-D (on linux) or CTRL-Z (on
windows). This sends an EOT control sequence which will prematurely
close irb.

Henning