]> arthur.barton.de Git - backup-script.git/blobdiff - bin/backup-audit
Fix and mark several notices & warnings of shellcheck(1)
[backup-script.git] / bin / backup-audit
index 0cf89e4440c14ba70913e36bd599499c8a46edf1..ef0a9e324d6c60e571ed1afea7020310acaa83d7 100755 (executable)
@@ -10,7 +10,7 @@
 # Please read the file COPYING, README and AUTHORS for more information.
 #
 
-NAME=`basename $0`
+NAME=$(basename "$0")
 
 VERBOSE=0
 QUIET=0
@@ -55,7 +55,7 @@ BeginDiff() {
 PipeDiff() {
        local line
        IFS=
-       while read line; do
+       while read -r line; do
                echo -e "     | $line"
        done
 }
@@ -110,6 +110,7 @@ HandleSystem() {
        echo "Found latest generation in \"$latest_d\"."
 
        declare -i code=-1
+       # shellcheck source=/dev/null
        source "$latest_d/.stamp"
 
        if [[ $code -ne 0 && $code -ne 24 ]]; then
@@ -119,10 +120,12 @@ HandleSystem() {
 
        # Search previous generation without errors
        local previous_d=""
-       for d in $(ls -1dt $target/[0-9]*-[0-9]* 2>/dev/null); do
+       # shellcheck disable=SC2045
+       for d in $(ls -1dt "$target/"[0-9]*-[0-9]* 2>/dev/null); do
                [[ -d "$d" && -r "$d/.stamp" ]] || return 0
 
                declare -i code=-1
+               # shellcheck source=/dev/null
                source "$d/.stamp"
 
                if [[ $code -eq 0 || $code -eq 24 ]]; then
@@ -212,10 +215,10 @@ DiffGenerations() {
 }
 
 MkTempFiles() {
-       tmp_1=$(mktemp /tmp/$NAME.XXXXXX) || exit 1
-       tmp_2=$(mktemp /tmp/$NAME.XXXXXX) || exit 1
-       tmp_diff=$(mktemp /tmp/$NAME.XXXXXX) || exit 1
-       tmp_out=$(mktemp /tmp/$NAME.XXXXXX) || exit 1
+       tmp_1=$(mktemp "/tmp/$NAME.XXXXXX") || exit 1
+       tmp_2=$(mktemp "/tmp/$NAME.XXXXXX") || exit 1
+       tmp_diff=$(mktemp "/tmp/$NAME.XXXXXX") || exit 1
+       tmp_out=$(mktemp "/tmp/$NAME.XXXXXX") || exit 1
 }
 
 CleanUp() {
@@ -263,7 +266,7 @@ MkTempFiles
 for f in "${sys[@]}"; do
        [[ -r "$f" && -f "$f" ]] || continue
 
-       fname=`basename $f`
+       fname=$(basename "$f")
        case "$fname" in
                "backup-script.conf"|*.sh)
                        continue