From c12f6cda2650e5415992877ad691de8c5144de6d Mon Sep 17 00:00:00 2001 From: earthlng Date: Mon, 19 Nov 2018 14:42:05 +0000 Subject: [PATCH] Update updater.sh - by moving `cd "$ff_profile"` to the Execute section we don't need to restore working directory if we hit the Exit 0 in File Handling - return 1 in confirmation() instead of exit and chained with `&& update_userjs` is functionally identical but always cleans up userjs_temps and restores the original working directory --- updater.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/updater.sh b/updater.sh index 526978c..dd8bd79 100755 --- a/updater.sh +++ b/updater.sh @@ -31,9 +31,8 @@ currdir=$(pwd) sfp=$(readlink -f "${BASH_SOURCE[0]}" 2>/dev/null || greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null) ## fallback for Macs without coreutils if [ -z "$sfp" ]; then sfp=${BASH_SOURCE[0]}; fi -## change directory to the Firefox profile directory +## store the Firefox profile directory ff_profile="$(dirname "${sfp}")" -cd $ff_profile ######################### @@ -48,7 +47,7 @@ elif [[ $(command -v "wget") ]] > /dev/null 2>&1; then elif [[ $(command -v "perl") ]]; then DOWNLOAD_METHOD="perl" else - echo -e ${RED}"This script requires curl, wget, or pearl to be installed.\nProcess aborted"${NC} + echo -e ${RED}"This script requires curl, wget or perl to be installed.\nProcess aborted"${NC} exit 0 fi @@ -119,7 +118,7 @@ confirmation () { if [[ $REPLY =~ ^[Nn]$ ]]; then echo -e ${RED}"Process aborted"${NC} - exit 1 + return 1 fi } @@ -133,7 +132,6 @@ get_updater_version () { filename=$1 version_regex='5 s/.*[[:blank:]]\([[:digit:]]*\.[[:digit:]]*\)/\1/p' echo "$(sed -n "$version_regex" "${ff_profile}/${filename}")" - } # Update updater.sh @@ -196,9 +194,11 @@ update_userjs () { # Execute # ######################### +## change directory to the Firefox profile directory +cd "$ff_profile" + initiate update_updater -confirmation -update_userjs +confirmation && update_userjs rm -rf userjs_temps -cd "${currdir}" \ No newline at end of file +cd "${currdir}"