]> arthur.barton.de Git - backup-script.git/commitdiff
Fix some warning messages of shellcheck(1)
authorAlexander Barton <alex@barton.de>
Tue, 26 Apr 2016 14:54:45 +0000 (16:54 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 26 Apr 2016 14:54:45 +0000 (16:54 +0200)
- SC1090: Can't follow non-constant source. Use a directive to
  specify location.

- SC2125: Brace expansions and globs are literal in assignments.
  Quote it or use an array.

- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.

See <http://www.shellcheck.net>.

bin/backup-script
bin/backup-status

index 4107e2425a614c2441fb9c2f1b96e2fb5368f0f1..626b5ec916f8028952f310f9a831f93bc050ada9 100755 (executable)
@@ -281,6 +281,7 @@ done
 # Read in configuration file
 config_info="Configuration file is \"$conf\""
 if [ -r "$conf" ]; then
+       # shellcheck source=/dev/null
        source "$conf"
 else
        config_info="${config_info} (not readable, using defaults)"
@@ -337,7 +338,7 @@ if [ $# -ge 1 ]; then
                sys="$sys ${conf_d}/$s"
        done
 else
-       sys="${conf_d}/"*
+       sys=("${conf_d}/"*)
 fi
 
 # check and create PID file
@@ -370,7 +371,7 @@ if [ -n "$pre_exec" ]; then
        echo
 fi
 
-for f in $sys; do
+for f in "${sys[@]}"; do
        [[ -r "$f" && -f "$f" ]] || continue
 
        fname=$(basename "$f")
@@ -410,6 +411,7 @@ for f in $sys; do
        unset post_exec
 
        # Read in system configuration file
+       # shellcheck source=/dev/null
        source "$f"
 
        # Compatibility with backup-pull(1) script: Fix up configuration
index eff19744b0c652519960d643705dafa41342785d..846f916edc6b0f3a078d9fe48200e7c686beae91 100755 (executable)
@@ -36,6 +36,7 @@ for conf in \
        "/usr/local/etc/backup-script.conf" \
 ; do
        if [ -r "$conf" ]; then
+               # shellcheck source=/dev/null
                source "$conf"
                break
        fi
@@ -76,6 +77,7 @@ Check_Stamp() {
                declare -i duration_t=-1
 
                # Read in "stamp file"
+               # shellcheck source=/dev/null
                source "$1"
 
                if [ $start_t -gt 0 ] && [ $end_t -gt 0 ]; then
@@ -140,12 +142,13 @@ Snapshot_Info() {
 
 Get_Result_Code() {
        code=1
+       # shellcheck source=/dev/null
        [ -r "$1" ] && source "$1"
        [ -z "$code" ] && code=1
        echo $code
 }
 
-if [ "$1" == "-r" -o "$1" == "--running" ]; then
+if [[ "$1" == "-r" || "$1" == "--running" ]]; then
        pid="$(cat "$PIDFILE" 2>/dev/null)"
        if [ -n "$pid" ]; then
                if kill -0 "$pid" >/dev/null 2>&1; then
@@ -192,11 +195,11 @@ if [ $# -ge 1 ]; then
                sys="$sys ${conf_d}/$s"
        done
 else
-       sys="${conf_d}/"*
+       sys=("${conf_d}/"*)
 fi
 
-for f in $sys; do
-       [ -r "$f" -a -f "$f" ] || continue
+for f in "${sys[@]}"; do
+       [[ -r "$f" && -f "$f" ]] || continue
 
        fname=`basename $f`
        case "$fname" in
@@ -211,6 +214,7 @@ for f in $sys; do
        generations="$default_generations"
 
        # Read in system configuration file
+       # shellcheck source=/dev/null
        source "$f"
 
        target="$target/$(basename "$f")"
@@ -221,7 +225,7 @@ for f in $sys; do
                [ $generations -gt 0 ] \
                        && result=$(Get_Result_Code "$target/latest/.stamp") \
                        || result=$(Get_Result_Code "$target/.stamp")
-               [ $result -eq 0 -o $result -eq 24 ] && continue
+               [[ $result -eq 0 || $result -eq 24 ]] && continue
        fi
 
        # System name