From 835c3556c98a5a6e5e6262d6d03852f7d2411c25 Mon Sep 17 00:00:00 2001 From: Isaac <100447932+iTawkins@users.noreply.github.com> Date: Thu, 8 Dec 2022 18:01:59 +0700 Subject: [PATCH] Update the flag implementation using getopts, and create an updater flag --- prefsCleaner.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/prefsCleaner.sh b/prefsCleaner.sh index 99b8981..60930a2 100755 --- a/prefsCleaner.sh +++ b/prefsCleaner.sh @@ -2,7 +2,7 @@ ## prefs.js cleaner for Linux/Mac ## author: @claustromaniac -## version: 1.5 +## version: 1.6 ## special thanks to @overdodactyl and @earthlng for a few snippets that I stol..*cough* borrowed from the updater.sh @@ -28,7 +28,8 @@ fUsage() { echo -e "\nUsage: $0 [-s]" echo -e " Optional Arguments: - -s Start immediately" + -s Start immediately + -u Update prefsCleaner.sh and execute silently. Do not seek confirmation." } fFF_check() { @@ -90,13 +91,29 @@ echo "This will allow inactive preferences to be reset to their default values." echo -e "\nThis Firefox profile shouldn't be in use during the process.\n" echo -e "\nIn order to proceed, select a command below by entering its corresponding number.\n" -[ "$1" == '-s' ] && fStart +## Flag implementation +while getopts "su" OPTION +do + case $OPTION in + s) + fStart + ;; + u) + download_file + update_updater + ;; + esac +done -select option in Start Help Exit; do +select option in Start Update Help Exit; do case $option in Start) fStart ;; + Update) + download_file + update_updater + ;; Help) fUsage echo -e "\nThis script creates a backup of your prefs.js file before doing anything."