On Tue, 22 Feb 2005 04:42:03 +0900, Joel VanderWerf  
<vjoel / PATH.Berkeley.EDU> wrote:

> Zev Blut wrote:
>> A coworker of mine just commented why not just use File.expand_path for
>> the required file?  Is there any reason not to do this?
>
> Symlinks...
>
> $ cd /tmp
> $ touch foo
> $ ln -s foo bar
> $ ruby -e 'p File.expand_path("foo")'
> "/tmp/foo"
> $ ruby -e 'p File.expand_path("bar")'
> "/tmp/bar"

Yes that is true, but I noticed if you actually go to directory with
a symlink, it will expand to the true path.  Like so:

$ cd /tmp/
$ mkdir foo
$ ln -s foo bar
$ touch foo/baz.rb
$ ruby -e 'Dir.chdir("foo") ;p File.expand_path("baz.rb")'
"/tmp/foo/baz.rb"
$ ruby -e 'Dir.chdir("bar") ;p File.expand_path("baz.rb")'
"/tmp/foo/baz.rb"

Is this portable or are there other problems with doing it this way?

Best,
Zev