setup.sh: link: fix issue creating unnecessary symlinks
As of now the link function follows the destination path if already existent and then creates a new symlink in there. In order to not create this unnecessary additional symlink a check has been added which simply checks if a symlink already exists in order to delete it.
This commit is contained in:
parent
f8fb7185c5
commit
27eefd62c8
1 changed files with 17 additions and 11 deletions
28
setup.sh
28
setup.sh
|
|
@ -13,17 +13,23 @@ link()
|
|||
local src="$(pwd)/$1"
|
||||
local dst="$2"
|
||||
|
||||
if test -e "$dst" && ! test -L "$dst"; then
|
||||
echo "File $dst exists and is no symlink.\nIgnore and continue? (y/N)"
|
||||
read answer
|
||||
case $answer in
|
||||
[Yy]*)
|
||||
return
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
if test -e "$dst"; then
|
||||
if ! test -L "$dst"; then
|
||||
echo "File $dst exists and is no symlink."
|
||||
echo "Ignore and continue? (y/N)"
|
||||
read answer
|
||||
case $answer in
|
||||
[Yy]*)
|
||||
return
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
# symlink already exists and will be removed
|
||||
rm "$dst"
|
||||
fi
|
||||
fi
|
||||
|
||||
if installed printf; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue