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.
Jeff C. (Guest)
on 2005-12-13 05: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
Gene T. (Guest)
on 2005-12-13 07:54
(Received via mailing list)
Jeff C. 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.
Damphyr (Guest)
on 2005-12-13 19:30
(Received via mailing list)
Gene T. 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.