Consider a folder bar
is a target to be created symbolic link to:
mkdir bar
Now create a symbolic link to bar
ln -s bar foo
# It will be now: foo -> bar
However running the same ln
command above again, an undesired symlink appears:
ln -s bar foo
# Instead of showing error of existing link
# the command creates a faulty link 'bar/bar'
Currently in order to avoid that faulty link I have to check first
if [[ ! -d foo ]]; then
ln -s bar foo
fi
That check is a solution, however, why is ln
command creating such faulty link? Any options to ln
command to tell the symlink is existing?