]> arthur.barton.de Git - backup-script.git/commitdiff
Use $() instead of ``
authorAlexander Barton <alex@barton.de>
Mon, 27 Jul 2015 13:08:26 +0000 (15:08 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 28 Jul 2015 14:07:29 +0000 (16:07 +0200)
This fixes some warnings of shellcheck(1).

bin/backup-script

index 60146d23f5a3d509a8b8ba0aaeb83a626b3a4f61..ee4ef2431b0a52ebe54e0c9020a170f748f28a22 100755 (executable)
@@ -10,7 +10,7 @@
 # Please read the file COPYING, README and AUTHORS for more information.
 #
 
-NAME=`basename $0`
+NAME=$(basename "$0")
 PIDFILE="/var/run/$NAME.pid"
 
 DRYRUN=0
@@ -194,7 +194,7 @@ fi
 for f in $sys; do
        [ -r "$f" -a -f "$f" ] || continue
 
-       fname=`basename $f`
+       fname=$(basename "$f")
        case "$fname" in
                "backup-script.conf"|*.sh)
                        continue
@@ -270,14 +270,14 @@ for f in $sys; do
                fi
 
                # Search directory of last generation, if any
-               last="`ls -1d "$sys_target"/[0-9]* 2>/dev/null | sort -r | head -n1`"
+               last=$(ls -1d "$sys_target"/[0-9]* 2>/dev/null | sort -r | head -n1)
                if [ -n "$last" ]; then
                        if [ ! -d "$last" ]; then
                                echo "Last snapshot \"$last\" seems not to be a directory!? \"$system\" skipped!"
                                echo; continue
                        fi
                fi
-               sys_target="$sys_target/`date +%Y%m%d-%H%M%S`"
+               sys_target="$sys_target/$(date +%Y%m%d-%H%M%S)"
 
                if [ -n "$last" -a ! -e "$last/.stamp" ]; then
                        # Old backup directory without "stamp file", continue
@@ -390,7 +390,7 @@ for f in $sys; do
                        ln -s "$sys_target" "$sys_root/latest"
                fi
                # Clean up old generations
-               to_delete=`ls -1t "$sys_root" 2>/dev/null | tail -n+$generations | sort`
+               to_delete=$(ls -1t "$sys_root" 2>/dev/null | tail -n+$generations | sort)
                if [ -n "$to_delete" -a $ok -eq 1 ]; then
                        [ "$DRYRUN" -eq 0 ] \
                                && echo "Deleting old backup generations:" \
@@ -401,8 +401,8 @@ for f in $sys; do
                                        echo "Not deleting \"$dir\", not a backup directory!?"
                                        continue
                                fi
-                               last=`stat "$dir/.stamp" 2>/dev/null | grep "^Modify: " \
-                                | cut -d':' -f2- | cut -d. -f1`
+                               last=$(stat "$dir/.stamp" 2>/dev/null | grep "^Modify: " \
+                                | cut -d':' -f2- | cut -d. -f1)
                                echo "Removing backup from" $last "..."
                                if [ "$DRYRUN" -eq 0 ]; then
                                        DeleteSubvolume \