merge func backupFail with backupFiles

This commit is contained in:
Asif Bacchus 2019-05-20 17:11:33 -06:00
parent e5d19aa871
commit 1d473633b1
1 changed files with 14 additions and 16 deletions

View File

@ -24,25 +24,23 @@ note="\e[95m"
function backupFiles {
# check if file exists
if [ -f "${F2B-DIR}/$1" ]; then
cp "${F2B-DIR}/$1" "${F2B-DIR}/$1.original"
return "$?"
if [ "$(cp "${F2B-DIR}/$1" "${F2B-DIR}/$1.original")" -ne 0 ]; then
echo
echo -e "${err}There was a problem backing up your current" \
"configuration."
echo -e "This suggests some kind of permissions error. Please" \
"remedy this and rerun"
echo -e "this script."
echo
echo -e "${note}Error backing up file: ${lit}$1"
echo
echo -e "${err}Exiting.${normal}"
echo
exit 100
fi
fi
return 0
}
function backupFail {
echo
echo -e "${err}There was a problem backing up your current configuration."
echo -e "This suggests some kind of permissions error. Please remedy this" \
"and rerun"
echo -e "this script."
echo
echo -e "${note}Error backing up file: ${lit}$1"
echo
echo -e "${err}Exiting.${normal}"
echo
exit 100
}
### end of functions