Package: localepurge
Version: 0.6.1
Severity: normal
Tags: patch
I'm sorry the previously posted patch didn't solve the whole Problem and
i ran into another one.
Initially you set globaltot=0 and in the spaceafter function you add the
tot of each dir you process by using ((globaltot += tot)).
Now if the actual dir didn't hold any files which got purged tot remains
0 (and if that happens while globaltot is 0) the expression becomes 0
which in case returns a status of 1 and the whole script exits for the
sakes of set -e.
So the solution is to only add tot to globaltot if tot is greater than 0.
I also forgot the ternary operator ((tot = before < after ? 0 : before -
after)) which indeed declares tot but turns the expression to 0 again.
--- a/localepurge 2010-01-03 02:27:54.000000000 +0100
+++ b/localepurge 2010-01-03 03:37:06.000000000 +0100
@@ -52,30 +52,28 @@ if [ "$1" = "--help" ] || [ "$1" = "-h"
fi
# Initialise local variables
-((true = 1))
-((false = 0))
-((VERBOSE = false))
-((DONTBOTHERNEWLOCALE = false))
-((SHOWFREEDSPACE = false))
-((MANDELETE = false))
-((globaltot = 0))
+VERBOSE=0
+DONTBOTHERNEWLOCALE=0
+SHOWFREEDSPACE=0
+MANDELETE=0
+globaltot=0
if fgrep --quiet --line-regexp DONTBOTHERNEWLOCALE $NOPURGECONF; then
- ((DONTBOTHERNEWLOCALE = true))
+ DONTBOTHERNEWLOCALE=1
fi
if fgrep --quiet --line-regexp SHOWFREEDSPACE $NOPURGECONF; then
- ((SHOWFREEDSPACE = true))
+ SHOWFREEDSPACE=1
fi
if fgrep --quiet --line-regexp MANDELETE $NOPURGECONF; then
- ((MANDELETE = true))
+ MANDELETE=1
fi
if fgrep --quiet --line-regexp VERBOSE $NOPURGECONF \
|| [ "$1" = "-verbose" ] || [ "$1" = "-v" ] \
|| [ "$2" = "-verbose" ] || [ "$2" = "-v" ]; then
- ((VERBOSE = true))
+ VERBOSE=1
fi
@@ -217,8 +215,8 @@ function spaceafter ()
if ((SHOWFREEDSPACE)); then
local dir="$1"
after=$(get_used_space "$dir")
- ((tot = before < after ? 0 : before - after))
- ((globaltot += tot))
+ tot=$((before < after ? 0 : before - after))
+ ((tot > 0)) && ((globaltot += tot))
echo "localepurge: Disk space freed in $dir: ${tot} KiB"
fi
}