It does not actually fail. It creates your link inside the given directory:
% mkdir dir_1 dir_2
% ln -s dir_1 symlink_dir
% ln -s dir_2 symlink_dir
% ls -l
total 0
drwxr-xr-x 2 user group 60 Oct 16 12:47 dir_1
drwxr-xr-x 2 user group 40 Oct 16 12:47 dir_2
lrwxrwxrwx 1 user group 5 Oct 16 12:47 symlink_dir -> dir_1
% ls -l dir_1
total 0
lrwxrwxrwx 1 user group 5 Oct 16 12:47 dir_2 -> dir_2
This behaviour is described in the manpage:
ln [OPTION]... TARGET... DIRECTORY (3rd form)
...
In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.
However, this link fails to link back to dir_2 as it is not set properly. This is also expected behaviour though, and not meant to fail. From the manpage:
Symbolic links can hold arbitrary text; if later resolved, a relative link is interpreted in relation to its parent directory.
By the way, it works the same way for me even with -sv
. Maybe you are using a different implementation of ln
. Are you sure you are not using -T
? Maybe that is set in your ~/.bashrc
/~/.zshrc
/etc. Try which ln
.
The question was cross-posted to Unix & Linux
– Der Hochstapler – 2014-03-18T08:13:56.847