dotfiles/lib/helper/rm_link
James Patrick e49934c99d Adding shared makefile logic and helper scripts
Shared logic can be imported via `include ../lib/shared.mk`
Helper functions include 3 current opperations

1. mk_link:: This will create a symbolic link if the file doesn't already exist.
2. rm_link:: Will remove the link if it is a symlink.
3. report :: This color codes the status of a message and adds a leading symbol.

report also can be called with `LAST_RETURN=$? report "message"`
and will expand this to be either `report info "message"` Or `report error
"message"` based on the last return value.
Current status are info, warn, and error.
2019-04-27 18:09:36 -04:00

21 lines
362 B
Bash
Executable File

#! env zsh
REPORT=`dirname $0`/report
if [[ -z $1 ]] ; then
$REPORT error "ERROR: Symlink to delete does not exist.\n symlink: $1"
exit
fi
if ! ( [[ -e $1 ]] || [[ -L $1 ]] ) ; then
$REPORT warn "$1 does not exist."
exit
fi
if [[ ! -L $1 ]] ; then
$REPORT warn "$1 is not a symbolic link. Skipping."
exit
fi
$REPORT info "Deleting $1"
rm $1