Warn for existing incorrect symlinks during setup

master
Jordan Atwood 2 years ago
parent dc42d786ae
commit 321585770f
Signed by: nightfirecat
GPG Key ID: 615A619C2D73A6DF
  1. 7
      setup.sh

@ -33,13 +33,16 @@ if [ $remove -eq 1 ]; then
elif [ $remove -eq 0 ]; then
# Ensure all files are absent in $HOME
for file in "${copy_files[@]}"; do
if [ -e "${HOME}/${file}" ] && ! [ -L "${HOME}/${file}" ]; then
source="${SRC_DIR}/${file}"
target="${HOME}/${file}"
if { [ -e "$target" ] && ! [ -L "$target" ]; } \
|| { [ -L "$target" ] && [[ "$source" != "$(readlink -f "$target")" ]]; }; then
files_to_remove+=( "$file" )
fi
done
if [ "${#files_to_remove}" -ne 0 ]; then
echo "Remove the following files from home directory and re-run setup!"
echo "Remove the following files/symlinks from home directory and re-run setup!"
printf '%s\n' "${files_to_remove[@]}"
exit 1
fi

Loading…
Cancel
Save