mirror of
https://github.com/kevinnlsamuel/bak-old.git
synced 2025-12-06 10:05:58 +05:30
handling unmet dependencies
- will prompt if `realpath` does not exist - need to work on the heredoc. insert new line for each dep
This commit is contained in:
31
bak-old.sh
31
bak-old.sh
@@ -11,7 +11,7 @@ version='0.1.0-beta'
|
|||||||
OLDIFS="$IFS"
|
OLDIFS="$IFS"
|
||||||
unset IFS
|
unset IFS
|
||||||
### error precautions
|
### error precautions
|
||||||
set -e
|
set -e
|
||||||
#####################
|
#####################
|
||||||
|
|
||||||
debug(){ ### function to call when $DEBUG is set
|
debug(){ ### function to call when $DEBUG is set
|
||||||
@@ -48,7 +48,7 @@ $(tput bold)OPTIONS$(tput sgr0)
|
|||||||
|
|
||||||
Help and Version
|
Help and Version
|
||||||
-h display this help menu
|
-h display this help menu
|
||||||
-v print version
|
-v print version
|
||||||
HERE
|
HERE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +80,16 @@ print_err(){
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print_err_deps(){
|
||||||
|
tput setaf 1
|
||||||
|
cat <<- EOF
|
||||||
|
${0##*/} has the following unmet dependencies:
|
||||||
|
${1/:/\\n}
|
||||||
|
EOF
|
||||||
|
tput sgr0
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
copy_succ(){
|
copy_succ(){
|
||||||
echo " ✅ $(tput setaf 2; tput bold)${1}.${2:-bak}$(tput sgr0)"
|
echo " ✅ $(tput setaf 2; tput bold)${1}.${2:-bak}$(tput sgr0)"
|
||||||
}
|
}
|
||||||
@@ -168,6 +178,23 @@ parse_combined(){
|
|||||||
${DEBUG+debug} ###
|
${DEBUG+debug} ###
|
||||||
### if $DEBUG is set ###
|
### if $DEBUG is set ###
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# CHECKING DEPS
|
||||||
|
##################
|
||||||
|
deps=(realpath)
|
||||||
|
|
||||||
|
for dep in $deps; do
|
||||||
|
if command -v "$dep"; then
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
missing="${dep}:"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -n ${missing} ]]; then
|
||||||
|
print_err_deps $missing
|
||||||
|
fi
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# SANITISING PARAMS AND OPTIONS
|
# SANITISING PARAMS AND OPTIONS
|
||||||
##################################
|
##################################
|
||||||
|
|||||||
Reference in New Issue
Block a user