"ln -sf" fails to replace existing target, if it is a symlink to a directory

Bug #120902 reported by Daniel Hahler
2
Affects Status Importance Assigned to Milestone
coreutils (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: coreutils

When using "ln -sf DIRECTORY SYMLINK-TO-ANOTHER-DIRECTORY" is does nothing!

Recipe:
$ mkdir foo1
$ mkdir foo2
$ ln -sf foo1 bar
$ ls -l
bar -> foo1/
foo1/
foo2/
$ ln -sf foo2 bar
$ ls -l
bar -> foo1/
foo1/
foo2/

Revision history for this message
Daniel Hahler (blueyed) wrote :

Wow. "it does nothing was wrong", using -v shows that:
$ LANG=C ln -sfv foo2 bar
create symbolic link `bar/foo2' to `foo2'

So it creates the symbolic link in the directory linked to by "bar".

Is this expected behaviour?
(Note that I do not have used a trailing slash at the end of the target name, which e.g. "rm" uses to distinguish between deleting the symlink or the directory.)

Revision history for this message
Micah Cowan (micahcowan) wrote :

Yes, it's expected behavior. By default, ln will dereference destination symlinks; use the -n option to avoid this.

$ ln -sfn foo2 bar
$ ls -l
bar -> foo2
foo1
foo2

Changed in coreutils:
status: Unconfirmed → Rejected
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.