aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcleaner.in12
1 files changed, 8 insertions, 4 deletions
diff --git a/cleaner.in b/cleaner.in
index 0413943..035892f 100755
--- a/cleaner.in
+++ b/cleaner.in
@@ -53,10 +53,14 @@ case $# in
esac
thisweek=$(date +%U)
+
+# Warning: do not use shell arithmetic expansions on week numbers,
+# because weeks prior to 10 begin with 0 and therefore are processed
+# as octal numbers. This causes grief for weeks 08 and 09.
if [ $thisweek -gt $retainweeks ]; then
- lastweek=$((thisweek - retainweeks))
+ lastweek=$(expr $thisweek - $retainweeks)
else
- lastweek=$((thisweek + 54 - retainweeks))
+ lastweek=$(expr $thisweek + 54 - $retainweeks)
fi
$verbose \# removing from $dir files ending in $suffix and older than week $lastweek
@@ -71,12 +75,12 @@ fi |
$verbose \# considering $name
week=$(expr "$name" : '[^-][^-]*-\([0-9][0-9]*\)-.*')
if [ $thisweek -ge $week ]; then
- if [ $((thisweek - week)) -gt $retainweeks ]; then
+ if [ $(expr $thisweek - $week) -gt $retainweeks ]; then
$verbose \# removing $name
$dry_run rm $dir/$name
fi
else
- if [ $((thisweek + 54 - week)) -gt $retainweeks ]; then
+ if [ $(expr $thisweek + 54 - $week) -gt $retainweeks ]; then
$verbose \# removing $name
$dry_run rm $dir/$name
fi

Return to:

Send suggestions and report system problems to the System administrator.