From 27eefd62c87822908e0b2c1d9c5afc1354274274 Mon Sep 17 00:00:00 2001 From: Thomas Preisner Date: Mon, 7 May 2018 01:51:06 +0200 Subject: [PATCH] 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. --- setup.sh | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/setup.sh b/setup.sh index f4c5cd7..de8e2fd 100755 --- a/setup.sh +++ b/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