Return codes

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?

Peter H. wrote:

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)

Perfect! Many thanks Tim.

2008/3/11, Peter H. [email protected]:

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