From: Henning Bekel Date: 2008-09-18T01:32:33+09:00 Subject: Re: irb shell exit 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_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