From: Alexander Barton Date: Mon, 27 Jul 2015 13:08:26 +0000 (+0200) Subject: Use $() instead of `` X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f49be9e17f6fba1f68551188013a262763b68f1;p=backup-script.git Use $() instead of `` This fixes some warnings of shellcheck(1). --- diff --git a/bin/backup-script b/bin/backup-script index 60146d2..ee4ef24 100755 --- a/bin/backup-script +++ b/bin/backup-script @@ -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 \