Forum: Ruby How to exit Ruby program properly

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8217faf2bfdfa7daf10135d41ddd421e?d=identicon&s=25 Jeff Cohen (jeff)
on 2005-12-13 04:57
I'm learning to write ruby code, and I'm using 1.8.2 on Windows XP.
What is the best way to exit from my .rb script?

I'm using Process.exit but the documentation implies that it will throw
an exception.  So I'm guessing there's a "cleaner" way to exit?

For example:

test.rb
====================
if ARGV.length == 0
  puts "Please specify a filename"
  Process.exit
end

# script continues here...


Thanks!
Jeff
9dfe8c734b0f9b37a4e218425c0a2138?d=identicon&s=25 Gene Tani (Guest)
on 2005-12-13 06:54
(Received via mailing list)
Jeff Cohen wrote:
> I'm learning to write ruby code, and I'm using 1.8.2 on Windows XP.
> What is the best way to exit from my .rb script?
>
> I'm using Process.exit but the documentation implies that it will throw
> an exception.  So I'm guessing there's a "cleaner" way to exit?
>

just to save you 3.5 seconds of searching, it's Kernel.exit and exit!
we're talking about in the docs.
Cfdeff3ac35010e4de8f85d954f24f4a?d=identicon&s=25 Damphyr (Guest)
on 2005-12-13 18:30
(Received via mailing list)
Gene Tani wrote:
>
> just to save you 3.5 seconds of searching, it's Kernel.exit and exit!
>  we're talking about in the docs.
Will this actually work if a Thread (unjoined) does it?
Should experiment before asking, but I am in the middle of something
else :)
Cheers,
V.-

--
http://www.braveworld.net/riva
This topic is locked and can not be replied to.