From db99afeb1961fede13b453e71a299096c817d434 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Tue, 7 Apr 2020 00:11:38 +0200 Subject: [PATCH] zfs_snapshot_cron.sh: fix bash leading 0 bug --- zfs_snapshot_cron.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zfs_snapshot_cron.sh b/zfs_snapshot_cron.sh index 2b454e6..ad7fa83 100755 --- a/zfs_snapshot_cron.sh +++ b/zfs_snapshot_cron.sh @@ -39,13 +39,13 @@ handle_pool() { if [ $D -gt 0 ]; then D=$(( D-1 )) echo "KEEP; D: $D" - elif [ $W -gt 0 ] && [ ${scomp[3]} -eq 1 ]; then + elif [ $W -gt 0 ] && [ ${scomp[3]#0} -eq 1 ]; then W=$(( W-1 )) echo "KEEP; W: $W" - elif [ $M -gt 0 ] && [ ${scomp[3]} -eq 1 ] && [ $(( scomp[4] % 4 )) -eq 0 ]; then + elif [ $M -gt 0 ] && [ ${scomp[3]#0} -eq 1 ] && [ $(( ${scomp[4]#0} % 4 )) -eq 0 ]; then M=$(( M-1 )) echo "KEEP; M: $M" - elif [ $Y -gt 0 ] && [ ${scomp[3]} -eq 1 ] && [ ${scomp[4]} -eq 4 ]; then + elif [ $Y -gt 0 ] && [ ${scomp[3]#0} -eq 1 ] && [ ${scomp[4]#0} -eq 4 ]; then Y=$(( Y-1 )) echo "KEEP; Y: $Y" else