dotfiles/lib/helper/mk_link

24 lines
457 B
Bash
Executable File

#! env zsh
# -*- sh -*-
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
fi
if [[ -e $2 ]] ; then
"$REPORT" info "$2 already exist. Skipping."
exit
fi
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`"