From 53b0e9011bd6050106ea21e84b46ed4324edf869 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Wed, 22 Jan 2020 23:01:07 -0500 Subject: [PATCH] install: handle existing links better Previously I would relink each existing link regardless of if it was up to date. It's better long-term to report up-to-date as its own status. --- install.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 1550d77..ffd7624 100755 --- a/install.sh +++ b/install.sh @@ -2,15 +2,24 @@ # Minimal install (no prereqs, just the basics) # Intended to be run on a new account, NOT for long term management # However, should be safe to rerun to fix/tune-up an existing install +set -e DOTFILES="$( cd "$(dirname "$0")" ; pwd -P )" # ln with the right settings and a nicer message try_ln() { + # bail out early if source doesn't exist + [ -e "$1" ] || return 0 + + # we know source is legit, set up dest if [ -e "$2" ]; then if [ -h "$2" ]; then - ln -snf $1 $2 - echo "[Updated Link] $2" | sed "s#$HOME#~#" + if [ `readlink $2` = "$1" ]; then + echo "[Up to Date ] $2" | sed "s#$HOME#~#" + else + ln -snf $1 $2 + echo "[Updated Link] $2" | sed "s#$HOME#~#" + fi else echo "[Fail:Exists ] $2" | sed "s#$HOME#~#" return -- libgit2 0.28.4