From 39632d150eb796a75b0bc1aae3c6f4ff50983727 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Fri, 13 Dec 2019 14:31:35 -0500 Subject: [PATCH] Added better reporting for mk_link. --- lib/helper/mk_link | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/helper/mk_link b/lib/helper/mk_link index 6d4f4e5..259ec82 100755 --- a/lib/helper/mk_link +++ b/lib/helper/mk_link @@ -5,12 +5,23 @@ REPORT="`dirname $0`/report" if [ -z "$1" ] || [ -z "$2" ] ; then "$REPORT" error "ERROR: Both to and from string must be defined.\n source: $1 \n symlnk: $2" - exit + exit -1 +fi + +if [[ -h $2 ]] ; then + link_location=$(readlink $2) + if [[ "$1" == "$link_location" ]] ; then + "$REPORT" info "symlink already installed $1" + exit 0 + else + "$REPORT" warn "symlink already exist, buut doesn't point to the src" + exit 1 + fi fi if [[ -e $2 ]] ; then - "$REPORT" info "$2 already exist. Skipping." - exit + "$REPORT" warn "Something already exists at $2." + exit 1 fi parent=$(dirname "$2")