[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

How to exit Ruby program properly

Jeff

12/13/2005 3:57:00 AM

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

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


2 Answers

Gene Tani

12/13/2005 5:51:00 AM

0


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.

Vassilis Rizopoulos

12/13/2005 5:27:00 PM

0

Gene Tani wrote:
> 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.
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.braveworl...

____________________________________________________________________
http://www.f... - äùñåÜí õðçñåóßá çëåêôñïíéêïý ôá÷õäñïìåßïõ.
http://www.f... - free email service for the Greek-speaking.