J
Joel VanderWerf
FileUtils.ln_s is supposed to do this:
ln_s(old, new, options = {})
Creates a symbolic link new which points to old. If new already
exists and it is a directory, creates a symbolic link +new/old+.
If new already exists and it is not a directory, raises
Errno::EEXIST. But if :force option is set, overwrite new.
But in this case something is wrong:
$ mkdir foo
$ echo 1>t.rb
$ ruby -r fileutils -e 'FileUtils.ln_s "t.rb", "foo/t.rb"'
$ ls -l foo
total 0
lrwxrwxrwx 1 vjoel vjoel 4 2009-06-12 14:47 t.rb -> t.rb
Why is this a cyclic link?
However, if the _old_ filename is in /tmp, there is no problem:
$ rm foo/t.rb
rm: remove symbolic link `foo/t.rb'? y
$ ruby -r fileutils -e 'FileUtils.ln_s "/tmp/t.rb", "foo/t.rb"'
$ ls -l foo
total 0
lrwxrwxrwx 1 vjoel vjoel 9 2009-06-12 14:48 t.rb -> /tmp/t.rb
This is with:
$ ruby -v
ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-linux]
ln_s(old, new, options = {})
Creates a symbolic link new which points to old. If new already
exists and it is a directory, creates a symbolic link +new/old+.
If new already exists and it is not a directory, raises
Errno::EEXIST. But if :force option is set, overwrite new.
But in this case something is wrong:
$ mkdir foo
$ echo 1>t.rb
$ ruby -r fileutils -e 'FileUtils.ln_s "t.rb", "foo/t.rb"'
$ ls -l foo
total 0
lrwxrwxrwx 1 vjoel vjoel 4 2009-06-12 14:47 t.rb -> t.rb
Why is this a cyclic link?
However, if the _old_ filename is in /tmp, there is no problem:
$ rm foo/t.rb
rm: remove symbolic link `foo/t.rb'? y
$ ruby -r fileutils -e 'FileUtils.ln_s "/tmp/t.rb", "foo/t.rb"'
$ ls -l foo
total 0
lrwxrwxrwx 1 vjoel vjoel 9 2009-06-12 14:48 t.rb -> /tmp/t.rb
This is with:
$ ruby -v
ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-linux]