From: Ryan Davis Date: 2007-07-03T05:47:07+09:00 Subject: Re: getting rid of $0 On Jul 2, 2007, at 11:11 , Alex Young wrote: > Tim Pease wrote: >> On 7/2/07, Michel Demazure wrote: >>> The common idiom >>> if __FILE__ == $0 then ... >>> gives bugs when $0 is not what one would expect, for instance >>> under a >>> debugger, or in rubyscript2exe, etc. >> require 'English' >> if __FILE__ == $PROGRAM_NAME > Does that solve the problem? Isn't that vulnerable to the same > issues as just using $0? Solve what problem? The code is doing what you asked it to do, that isn't a problem, that's programming. The code clearly reads "if this file is the program" which is NOT the case when run under a debugger. I'm not sure what rubyscript2exe generates, but my guess is that can be solved on their end somehow. I generally don't want that code to run when I'm poking around in a debugger or something similar. If I do, I set the values inside the debugger and don't worry about it.