From: Robert Klemme Date: 2004-04-30T20:39:00+09:00 Subject: Re: File.expand_path(__FILE__) "Simon Strandgaard" schrieb im Newsbeitrag news:20040430124420.2f2b621b.neoneye@adslhome.dk... > "Robert Klemme" wrote: > > "Simon Strandgaard" schrieb im Newsbeitrag > > > > > > Maybe extend __FILE__ with a #absolute method, > > > in order to make __FILE__ immune against chdir ? > > > > This is easily fixed: > > > > FILE = File.expand_path __FILE__ > > p [__FILE__, FILE] > > Not if the person has done a chdir just before expand_path. Well, I should've written "first line in script". > I wonder why __FILE__ isn't an absolute path. Relative paths is > just too fragile. > > > Proposal: make __FILE__ an absolute path. > That would make __FILE__ robust to Dir.chdir. > > > Any thoughts on this proposal? fore or against Slightly against, because - it's easily fixed - you loose information: there might be situations where the script wants to know the exact path it was invoked with. - most of the time (when invoked from the shell via path expansion) scripts are invoked with an absolute path anyway. Kind regards robert