irb shell exit

S

Scott Harper

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-forum.com/attachment/2706/irb_shell_exit.JPG
 
N

Nathan Powell

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 ~ $ irbnpowell@delilah ~ $





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

Clinton D. Judy

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:[email protected]]=20
Sent: Wednesday, September 17, 2008 11:36 AM
To: ruby-talk ML
Subject: Re: irb shell exit

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=20npowell@delilah ~ $=20




=20
Can someone please help?
=20
Thanks!
=20
Attachments:
http://www.ruby-forum.com/attachment/2706/irb_shell_exit.JPG
=20
--=20
Posted via http://www.ruby-forum.com/.
=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
------------------------------------
 
T

Thomas B.

Clinton said:
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-step.html

TPR.
 
S

Scott Harper

Thomas said:
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-step.html

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
 
H

Henning Bekel

Scott said:
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_shell_exit.JPG

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
 

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,780
Messages
2,569,608
Members
45,252
Latest member
MeredithPl

Latest Threads

Top