Project

General

Profile

Bug #8501

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago

=begin 
 Actual Behaviour: 

                                                                                                                                                                                                    
                                                                                                                                                                                                                    
 Running this file: 

                                                                                                                                                                                                     

 ```                                                                                                                                                                                                                    
 class MyStupidClass 
                                                                                                                                                                                                    
   def self.inspect 
                                                                                                                                                                                                       
     raise "LOOOOOL" 
                                                                                                                                                                                                    
   end 
                                                                                                                                                                                                                
 end 

                                                                                                                                                                                                                  

 at_exit { p $! } 
                                                                                                                                                                                                     
 at_exit { MyStupidClass.nope } 

                                                                                                                                                                                     
 ``` 
                                                                                                                                                                                                                    
 gives a 0 exit code and the following output: 

                                                                                                                                                                          

 ``` 
                                                                                                                                                                                                                    
   foo.rb:8:in `block in <main>': undefined method `nope' for #<Class:0x007fe30b946740> (NoMethodError) 
                                                                                                                 
   nil 

 
 ```                                                                                                                                                                                                                
                                                                                                                                                                                                                    
 Expected Behaviour: 

                                                                                                                                                                                                  
                                                                                                                                                                                                                    
 A non-zero exit code, and $! populated in the at_exit hook. 

                                                                                                                                                          
                                                                                                                                                                                                                    
 Notes 

                                                                                                                                                                                                                
                                                                                                                                                                                                                    
 Reproducible on ruby 2.1.0dev (2013-06-08), 2.0.0p0 and 1.9.3p392. 

                                                                                                                                                   
                                                                                                                                                                                                                    
 On 1.8.7 the output is: 

                                                                                                                                                                                                
 ```                                                                                                                                                                                                                     
   foo.rb:8: undefined method `nope' for #<Class:0x10de056b0> (NoMethodError) 
                                                                                                                                                   
           from foo.rb:8 
                                                                                                                                                                                                
   #<fatal: exception reentered> 

                                                                                                                                                                                      
 ```                                                                                                                                                                                                                     
 And the exit code is 1. 
 =end 
                                                                                                                                                                                              

Back