I have an issue with creating symbolic links with ln
, with the relative and the force flag set.
The scenario is as follows:
$ tree
.
├── folder1
│ └── file
└── folder2
I create the link:
$ ln -sfr folder1/file folder2
$ tree
.
├── folder1
│ └── file
└── folder2
└── file -> ../folder1/file
This is as I want it. But when I re-execute the command, I don't understand why the link is now pointing to itself:
$ ln -sfr folder1/file folder2
$ tree
.
├── folder1
│ └── file
└── folder2
└── file -> file
Executing the command a third time corrects the error:
$ ln -sfr folder1/file folder2
$ tree
.
├── folder1
│ └── file
└── folder2
└── file -> ../folder1/file
Re-executing the command multiple times toggles between two states. I really wonder why this is. According to the manual this should be no issue.
The ln
version used (as shipped with Ubuntu 14.10):
$ ln --version
ln (GNU coreutils) 8.21
[...]