aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-02-25 12:58:58 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2013-02-25 12:59:49 +0200
commit194f4b1204d6e49ba0af7dd761f8c794ba37c035 (patch)
tree5a06c5ee99cbaa8c7fac590c884dd4626d73d587
parent10fe71da645b70c4c59079a0c84317170e806a9d (diff)
downloadbeam-194f4b1204d6e49ba0af7dd761f8c794ba37c035.tar.gz
beam-194f4b1204d6e49ba0af7dd761f8c794ba37c035.tar.bz2
Bugfix in cleaner
* cleaner.in: 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.
-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.