Red Hat Bugzilla – Bug 115167
"-f" option ignored by "ln"
Last modified: 2007-11-30 17:10:36 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040116
Description of problem:
The "-f" ("--force") option in "ln" doesn't seem to have any effect
except supress the error message when the symlink already exists.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. mkdir a b
2. ln -s a c
3. ln -sf b c
Actual Results: After step 3 the symlink "c" still points at "a".
Expected Results: It should point at "b", the "f" option should force
the old symlink to be eliminated and the new one to be created
pointing at "b".
I think this is not a bug.
$ mkdir a b
$ ln -s a c
$ ln -sf b c
$ ls -l
drwxrwxr-x 2 bart bart 4096 Feb 8 11:30 a
drwxrwxr-x 2 bart bart 4096 Feb 8 11:30 b
lrwxrwxrwx 1 bart bart 1 Feb 8 11:30 c -> a
$ ls -l c/
lrwxrwxrwx 1 bart bart 1 Feb 8 11:30 b -> b
I see what you mean. I didn't notice that the second ln was creating a
symlink called "b" inside directory "c". I almost sure that this
behavior was introduced not long ago as I remember doing the kind of
command sequence indicated above with the results I expected.
The way to get the result I want is by doing "ln -sfn" to avoid
dereferencing the existing symlink. I'm closing this but I feel that
something should be done to make this explicit in the documentation
(at least for those like me that expected the present behavior only
when using "c/" instead of just "c").