Hal Fulton <hal9000 / hypermetrics.com> wrote:
> Simon Strandgaard wrote:
> > On Fri, 30 Apr 2004 05:28:43 +0900
> > John Platte <john.platte / nikaconsulting.com> wrote:
> > 
> >>I'm having a problem with File.expand_path(__FILE__) after a chdir. 
> >>Looks like a bug in Ruby to me. If someone can tell me what I'm doing 
> >>wrong, I'd be grateful.
> > 
> > I guess you assume that __FILE__ change when doing chdir.
> > But it doesn't
> 
> I think you've analyzed this incorrectly.
> 
> The value of __FILE__ doesn't change, nor did he expect it to.
> But expand_path is giving him an erroneous result, is it not?
> 
> "/Users/ryan/tmp/tmp/demo-problem.rb" -- there is no tmp/tmp
> directory if I understand correctly.
> 
> It does look like a bug to me.

No bug.


At the last line "File.expand_path(__FILE__)" is being invoked.
Currend dir = "/Users/ryan/tmp/"
File name = "tmp/demo-problem.rb"

When these are being concatenated it outputs
absolut path = "/Users/ryan/tmp/tmp/demo-problem.rb"


concat is working ok.

--
Simon Strandgaard