37979608095d7847a6fba081ff9e582e52842253

Author
zertrin <zertrin@gmail.com>
Committer
zertrin <zertrin@gmail.com>
Date

Message

massive cleaning with shellcheck: from 5 errors and 200 warnings to zero

Diff

This diff is truncated to protect this page.

  1diff --git a/duplicity-backup.sh b/duplicity-backup.sh
  2index 94e16dbd3184d78dc9af903a1b8f4b3ae7fa01ea..a194837dba6e914ee1157582bc19f00827931fc7 100755
  3--- a/duplicity-backup.sh
  4+++ b/duplicity-backup.sh
  5@@ -44,7 +44,7 @@ CONFIG="duplicity-backup.conf"
  6 
  7 usage(){
  8 echo "USAGE:
  9-    `basename $0` [options]
 10+  $(basename "$0") [options]
 11 
 12   Options:
 13     -c, --config CONFIG_FILE   specify the config file to use
 14@@ -73,8 +73,8 @@ echo "USAGE:
 15   CURRENT SCRIPT VARIABLES:
 16   ========================
 17     DEST (backup destination)       = ${DEST}
 18-    INCLIST (directories included)  = ${INCLIST[@]:0}
 19-    EXCLIST (directories excluded)  = ${EXCLIST[@]:0}
 20+    INCLIST (directories included)  = ${INCLIST[*]:0}
 21+    EXCLIST (directories excluded)  = ${EXCLIST[*]:0}
 22     ROOT (root directory of backup) = ${ROOT}
 23     LOGFILE (log file path)         = ${LOGFILE}
 24 "
 25@@ -88,45 +88,45 @@ while getopts ":c:t:bfvlsnd-:" opt; do
 26     # parse long options (a bit tricky because builtin getopts does not
 27     # manage long options and I don't want to impose GNU getopt dependancy)
 28     -)
 29-      case "$OPTARG" in
 30+      case "${OPTARG}" in
 31         # --restore [restore dest]
 32         restore)
 33-          COMMAND=$OPTARG
 34+          COMMAND=${OPTARG}
 35           # We try to find the optional value [restore dest]
 36           if [ ! -z "${!OPTIND:0:1}" -a ! "${!OPTIND:0:1}" = "-" ]; then
 37             RESTORE_DEST=${!OPTIND}
 38-            OPTIND=$(( $OPTIND + 1 )) # we found it, move forward in arg parsing
 39+            OPTIND=$(( OPTIND + 1 )) # we found it, move forward in arg parsing
 40           fi
 41         ;;
 42         # --restore-file [file to restore] [restore dest]
 43         # --restore-dir [path to restore] [restore dest]
 44         restore-file|restore-dir)
 45-          COMMAND=$OPTARG
 46+          COMMAND=${OPTARG}
 47           # We try to find the first optional value [file to restore]
 48           if [ ! -z "${!OPTIND:0:1}" -a ! "${!OPTIND:0:1}" = "-" ]; then
 49             FILE_TO_RESTORE=${!OPTIND}
 50-            OPTIND=$(( $OPTIND + 1 )) # we found it, move forward in arg parsing
 51+            OPTIND=$(( OPTIND + 1 )) # we found it, move forward in arg parsing
 52           else
 53             continue # no value for the restore-file option, skip the rest
 54           fi
 55           # We try to find the second optional value [restore dest]
 56           if [ ! -z "${!OPTIND:0:1}" -a ! "${!OPTIND:0:1}" = "-" ]; then
 57             RESTORE_DEST=${!OPTIND}
 58-            OPTIND=$(( $OPTIND + 1 )) # we found it, move forward in arg parsing
 59+            OPTIND=$(( OPTIND + 1 )) # we found it, move forward in arg parsing
 60           fi
 61         ;;
 62         config) # set the config file from the command line
 63           # We try to find the config file
 64           if [ ! -z "${!OPTIND:0:1}" -a ! "${!OPTIND:0:1}" = "-" ]; then
 65             CONFIG=${!OPTIND}
 66-            OPTIND=$(( $OPTIND + 1 )) # we found it, move forward in arg parsing
 67+            OPTIND=$(( OPTIND + 1 )) # we found it, move forward in arg parsing
 68           fi
 69         ;;
 70         time) # set the restore time from the command line
 71           # We try to find the restore time
 72           if [ ! -z "${!OPTIND:0:1}" -a ! "${!OPTIND:0:1}" = "-" ]; then
 73             TIME=${!OPTIND}
 74-            OPTIND=$(( $OPTIND + 1 )) # we found it, move forward in arg parsing
 75+            OPTIND=$(( OPTIND + 1 )) # we found it, move forward in arg parsing
 76           fi
 77         ;;
 78         dry-run)
 79@@ -136,13 +136,13 @@ while getopts ":c:t:bfvlsnd-:" opt; do
 80           ECHO=$(which echo)
 81         ;;
 82         *)
 83-          COMMAND=$OPTARG
 84+          COMMAND=${OPTARG}
 85         ;;
 86         esac
 87     ;;
 88     # here are parsed the short options
 89-    c) CONFIG=$OPTARG;; # set the config file from the command line
 90-    t) TIME=$OPTARG;; # set the restore time from the command line
 91+    c) CONFIG=${OPTARG};; # set the config file from the command line
 92+    t) TIME=${OPTARG};; # set the restore time from the command line
 93     b) COMMAND="backup";;
 94     f) COMMAND="full";;
 95     v) COMMAND="verify";;
 96@@ -151,29 +151,29 @@ while getopts ":c:t:bfvlsnd-:" opt; do
 97     n) DRY_RUN="--dry-run ";; # dry run
 98     d) ECHO=$(which echo);; # debug
 99     :)
100-      echo "Option -$OPTARG requires an argument." >&2
101+      echo "Option -${OPTARG} requires an argument." >&2
102       COMMAND=""
103     ;;
104     \?)