From 5b81a2827b2cea9ecb5c9abe5b5eecae532e7847 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Fri, 13 Dec 2019 12:36:07 -0500 Subject: [PATCH] Added Step that create parent dir in symlinking. --- lib/helper/mk_link | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/helper/mk_link b/lib/helper/mk_link index 15ce8c6..6d4f4e5 100755 --- a/lib/helper/mk_link +++ b/lib/helper/mk_link @@ -1,17 +1,23 @@ #! env zsh # -*- sh -*- -REPORT=`dirname $0`/report +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" + "$REPORT" error "ERROR: Both to and from string must be defined.\n source: $1 \n symlnk: $2" exit fi if [[ -e $2 ]] ; then - $REPORT warn "$2 already exist. Skipping." + "$REPORT" info "$2 already exist. Skipping." exit fi -$REPORT info "Symlinked `ln -svf $1 $2`" +parent=$(dirname "$2") +if [[ ! -e $parent ]] ; then + "$REPORT" warn "$parent doesn't exist. Creating." + mkdir -p $parent +fi + +"$REPORT" info "Symlinked `ln -svf $1 $2`"