2011/2/1 Eric Hodel <drbrain / segment7.net>:
>> Hi, my program invokes "exit true" or "exit false" and I want to catch
>> such return code into at_exit() block, but I don't know how to do
>> that.
>
> ruby -e 'at_exit { p $!.status }; exit 1'

Really interesting. However, it fails if exit() is called outside of the scope:

irb> at_exit { p "$!.inspect = #{$!.inspect}" }
#<Proc:0x000000019f99c0@(irb):1>
irb> exit 1
"$!.inspect = nil"

So $! is nil and I cannot get $!.status.


-- 
Iaki Baz Castillo
<ibc / aliax.net>