You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you run a Ruby command with multiple -e arguments, those "inline scripts" should be executed to completion, each in turn.
The ordering of END and at_exit is also unexpected here. It appears that CRuby always splices END and at_exit to run at the termination of the top-level script...which in this case happens after both -e scripts have run:
$ ruby23 -e "
BEGIN { puts 0 }
puts :a
END { puts 1 }
at_exit { puts 2 }"
-e "
BEGIN { puts 3 }
puts :b
END { puts 4 }
at_exit { puts 5 }"
0
3
a
b
5
4
2
1
@enebo showed me some examples with required files that also show that END blocks are registered in the same process as at_exit blocks and run in reverse order the same way.
We match some of this ordering, but for cases where exceptional results come out of the scripts, things get a little weird:
Here, the second block of code does not get to the point of registering its END and at_exit blocks, so they don't run...ok. But the END and at_exit from the first block of code appear to run before the second block of code fails.
JRuby runs this differently, with the raises in END and at_exit coming after the raise in the second block of code:
$ jruby -e "END { raise '1' }; at_exit { raise '2' }" -e "raise 'b'; END { raise '4' }; at_exit { raise '5' }"
RuntimeError: b
<top> at -e:2
RuntimeError: 2
block in -e at -e:1
RuntimeError: 1
block in -e at -e:1
These ordering behaviors and the multiple -e behavior probably need specs. I will be taking some MRI tests since I don't see these as common cases and they're nontrivial to fix right now.
The text was updated successfully, but these errors were encountered:
When you run a Ruby command with multiple
-e
arguments, those "inline scripts" should be executed to completion, each in turn.The ordering of
END
andat_exit
is also unexpected here. It appears that CRuby always splicesEND
andat_exit
to run at the termination of the top-level script...which in this case happens after both-e
scripts have run:@enebo showed me some examples with required files that also show that
END
blocks are registered in the same process asat_exit
blocks and run in reverse order the same way.We match some of this ordering, but for cases where exceptional results come out of the scripts, things get a little weird:
Here, the second block of code does not get to the point of registering its
END
andat_exit
blocks, so they don't run...ok. But theEND
andat_exit
from the first block of code appear to run before the second block of code fails.JRuby runs this differently, with the raises in
END
andat_exit
coming after the raise in the second block of code:These ordering behaviors and the multiple
-e
behavior probably need specs. I will be taking some MRI tests since I don't see these as common cases and they're nontrivial to fix right now.The text was updated successfully, but these errors were encountered: