From c3f6db0ce8aed9fd32a44fabf2597d8ee83c6d9f Mon Sep 17 00:00:00 2001 From: 3coma3 <3coma3@gmail.com> Date: Wed, 30 Jun 2021 22:43:12 -0300 Subject: [PATCH] fix: bugs in cmd_test() bug #1: serial generator ommited the seconds fix: include the seconds bug #2: dupe detection wrongly set empty string, then attempted to detect a new entry checking for empty string fix: set the $results entry to non empty (just use $count) --- backup | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backup b/backup index 0b839c4..5278276 100755 --- a/backup +++ b/backup @@ -325,13 +325,12 @@ cmd_test() { (( y = RANDOM % (yr + 1) + $(date +%Y) - yr, m = RANDOM % 12 + 1 )) (( leapfeb = ! (y % 4 || ! y % 100 && y % 400) && m == 2 )) (( d = RANDOM % (daysmonth[m - 1] + leapfeb) + 1 )) - (( h = RANDOM % 23 + 1, mi = RANDOM % 59 + 1 )) + (( h = RANDOM % 23 + 1, mi = RANDOM % 59 + 1 , s = RANDOM % 59 + 1 )) - new="$(printf "%02d/%02d/%02d/%02d%02d" $y $m $d $h $mi)" + new="$(printf "%02d/%02d/%02d/%02d%02d%02d" $y $m $d $h $mi $s)" [[ -z "${results[$new]:-}" ]] && { - results[$new]='' + (( results[$new] = count-- )) echo "$destination/$new" - (( count-- )) } done | sort -dr | tokenize_path | check_retention --all | rotate_test }