Return codes

P

Peter Hug

I'd like to be able to launch a little ruby application from within a
shell script or a windows command file. How can my Ruby application
return error or success codes such that the callee can verify the result
easily both in Linux and Windows?
 
T

Tim Hunter

Peter said:
I'd like to be able to launch a little ruby application from within a
shell script or a windows command file. How can my Ruby application
return error or success codes such that the callee can verify the result
easily both in Linux and Windows?

$ ri Kernel#exit
------------------------------------------------------------ Kernel#exit
exit(integer=0)
Kernel::exit(integer=0)
Process::exit(integer=0)
 
R

Robert Klemme

2008/3/11 said:
Perfect! Many thanks Tim.

Additional note: it is sufficient to throw an exception or not. Ruby
will automatically set the exit code appropriately:

18:06:55 /cygdrive/c/SCMws/Tickets/oz-26255_no_txid
$ ruby -e '123'; echo $?
0
18:07:03 /cygdrive/c/SCMws/Tickets/oz-26255_no_txid
$ ruby -e 'raise "foo"'; echo $?
-e:1: foo (RuntimeError)
1
18:07:06 /cygdrive/c/SCMws/Tickets/oz-26255_no_txid
$

Kind regards

robert
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top