Почему одна и та же команда ln выполняется по-разному?Linux

Гость
Почему одна и та же команда ln выполняется по-разному?

Сообщение Гость »


Рассмотрим папку 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 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 command creating such faulty link? Any options to command to tell the symlink is existing?


Источник: https://stackoverflow.com/questions/781 ... ifferently

Вернуться в «Linux»