]> arthur.barton.de Git - backup-script.git/commitdiff
backup-status: Refactor argument parsing
authorAlexander Barton <alex@barton.de>
Wed, 19 Aug 2015 08:06:33 +0000 (10:06 +0200)
committerAlexander Barton <alex@barton.de>
Wed, 19 Aug 2015 08:06:33 +0000 (10:06 +0200)
bin/backup-status

index 4ba22f3a894abe6996f1c30a424508b045df60b4..edbdd64cc1c6fa62c553e2fc446ccbe16ef77bbf 100755 (executable)
@@ -39,6 +39,12 @@ for conf in \
        fi
 done
 
+Usage() {
+       echo "Usage: $NAME [-q|--quick] [<system> [<system> [...]]]"
+       echo "       $NAME {-r|--running}"
+       exit 2
+}
+
 Check_Size() {
        # $1: directory
        # $2: padding
@@ -91,18 +97,19 @@ if [ "$1" == "-r" -o "$1" == "--running" ]; then
        exit 1
 fi
 
-if [ "$1" == "-q" ]; then
-       QUICK=1
+while [ $# -gt 0 ]; do
+       case "$1" in
+               "--quick"|"-q")
+                       QUICK=1
+                       ;;
+               "-"*)
+                       Usage
+                       ;;
+               *)
+                       break
+       esac
        shift
-fi
-
-case "$1" in
-    "-"*)
-       echo "Usage: $NAME [-q] [<system> [<system> [...]]]"
-       echo "       $NAME {-r|--running}"
-       exit 2
-       ;;
-esac
+done
 
 if [ $# -ge 1 ]; then
        for s in "$@"; do