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:
Thomas Preisner 2018-05-07 01:51:06 +02:00
parent f8fb7185c5
commit 27eefd62c8

View file

@ -13,8 +13,10 @@ link()
local src="$(pwd)/$1" local src="$(pwd)/$1"
local dst="$2" local dst="$2"
if test -e "$dst" && ! test -L "$dst"; then if test -e "$dst"; then
echo "File $dst exists and is no symlink.\nIgnore and continue? (y/N)" if ! test -L "$dst"; then
echo "File $dst exists and is no symlink."
echo "Ignore and continue? (y/N)"
read answer read answer
case $answer in case $answer in
[Yy]*) [Yy]*)
@ -24,6 +26,10 @@ link()
exit 1 exit 1
;; ;;
esac esac
else
# symlink already exists and will be removed
rm "$dst"
fi
fi fi
if installed printf; then if installed printf; then