From: Philip Hallstrom Date: 2007-01-12T05:39:52+09:00 Subject: Re: Finding path to ruby script argument > On 1/11/07, Matthew Hailstone wrote: >> Looks like __FILE__ and $0 are the same. > > Not necessarily... when running a script under rcov or similar, they > may differ (for example one starts with ./ while the other does not). > That's why I write the if __FILE__ == $0 idiom as > > if File.expand_path(__FILE__) == File.expand_path($0) > > Another possibility might be is when you start the script using $PATH, > i.e. not from current directory, but without specifying its path. Also, and i haven't even bothered to test this, but if it's similar to PHP's FILE variable, it's the *current* file... so require a file, call a method in that file, and access __FILE__ in that method and you're gonna get your required file, not the initial one... -philip