From 1d473633b14c976f9bdb01e4441c10263a21f515 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Mon, 20 May 2019 17:11:33 -0600 Subject: [PATCH] merge func backupFail with backupFiles --- f2b-config.sh | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/f2b-config.sh b/f2b-config.sh index d61b422..da0f65a 100644 --- a/f2b-config.sh +++ b/f2b-config.sh @@ -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