Bug #12302
Updated by nobu (Nobuyoshi Nakada) over 8 years ago
~~~ruby ~~~ at_exit do puts "1 #{$!}" end at_exit do puts "2 #{$!}" raise 'x' rescue nil end at_exit do puts "3 #{$!}" exit 1 end ~~~ Nr 3 runs first and exits 1 ... Nr2 receives the correct exit status ... but using raise/rescue there overrides `$!` $1 and Nr 1 thinks it is a clean exit ... seems semi related to https://bugs.ruby-lang.org/issues/5218 ... ideally the `at_exit` at_exit block should restore the previous `$!` $! ... or give some other way of knowing the exit status like passing it to the block ~~~ruby ~~~ at_exit do |exception| |exception} ... end ~~~