From 74ba4615d1bc033ff54471842e6123dd2846cfaa Mon Sep 17 00:00:00 2001 From: David Todd Date: Tue, 12 Jan 2021 14:28:05 -0600 Subject: [PATCH] improve symlink function --- install.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index 04d7eda..ad8c943 100755 --- a/install.sh +++ b/install.sh @@ -27,23 +27,23 @@ function symlink() { src=$1 dest=$2 - if [ -e $dest ]; then - if [ -L $dest ]; then + if [ -e "${dest}" ]; then + if [ -L "${dest}" ]; then # Already symlinked -- I'll assume correctly. return else # Rename files with a ".old" extension. - echo "$dest already exists, renaming to $dest.old" - backup=$dest.old - if [ -e $backup ]; then + echo "${dest} already exists, renaming to ${dest}.old" + backup="${dest}.old" + if [ -e "${backup}" ]; then echo "Error: $backup already exists. Please delete or rename it." exit 1 fi - mv -v $dest $backup + mv -v "${dest}" "${backup}" fi fi - echo "Linking $(basename $src)..." - ln -sf $src $dest + echo "Linking $(basename "${src}")..." + ln -sf "${src}" "${dest}" } read -p "Press enter to install dotfiles " WAIT_FOR_INPUT