From: Robert Klemme Date: 2004-04-30T17:04:01+09:00 Subject: Re: File.expand_path(__FILE__) "Simon Strandgaard" schrieb im Newsbeitrag news:20040430022720.4b2c5b05.neoneye@adslhome.dk... > Hal Fulton wrote: > > Simon Strandgaard wrote: > > > I think concat are the desired behavier of expand_path. > > > For instance if you want to create a directory, you first > > > have to make the path, before you make it. I don't have > > > better evidence. > > > > I see your point, and I don't have a counterexample. > > > > And I guess there is a problem with what the OP wanted -- > > if the original name is relative to the original current > > directory, then the interpreter would have to keep track > > of where we were relative to our original dir. > > > > It is doable, but is it worth it? And is there a real > > purpose to expand_path besides tilde substitution and > > simple concatenation? > > > Maybe extend __FILE__ with a #absolute method, > in order to make __FILE__ immune against chdir ? This is easily fixed: 09:58:20 [ruby]: /cygdrive/c/temp/ruby/pfile.rb ["/cygdrive/c/temp/ruby/pfile.rb", "/cygdrive/c/temp/ruby/pfile.rb"] 09:58:31 [ruby]: ./pfile.rb ["./pfile.rb", "/cygdrive/c/temp/ruby/pfile.rb"] 09:58:38 [ruby]: ruby pfile.rb ["pfile.rb", "/cygdrive/c/temp/ruby/pfile.rb"] 09:58:40 [ruby]: cat pfile.rb #!/usr/bin/ruby FILE = File.expand_path __FILE__ p [__FILE__, FILE] Regards robert