Почему одна и та же команда 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
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

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