summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xw3watch76
1 files changed, 36 insertions, 40 deletions
diff --git a/w3watch b/w3watch
index 88400ae..6eabdd4 100755
--- a/w3watch
+++ b/w3watch
@@ -55,59 +55,55 @@ list() {
}
check() {
- while read line; do
- if echo "${line}" | grep -q -v '^#'; then
- data=(${line})
- url="${data[0]}"
- filter="${data[@]:1}"
-
- if echo "$url}" | grep -q '^@'; then
- url="$(echo "${url}" | cut -c 1 --complement -)"
- dump=$($LYNX -source "$url")
- else
- dump=$($LYNX -dump "$url")
- fi
-
- if [ $? -ne 0 ]; then
- continue
- fi
-
- if [ "${filter}" != "" ]; then
- dump=$(echo "${dump}" | eval "${filter}")
- fi
+ grep -v '^#' "${CONFIGFILE}" | while read line; do
+ data=(${line})
+ url="${data[0]}"
+ filter="${data[@]:1}"
+
+ if echo "$url}" | grep -q '^@'; then
+ url="$(echo "${url}" | cut -c 1 --complement -)"
+ dump=$($LYNX -source "$url")
+ else
+ dump=$($LYNX -dump "$url")
+ fi
- if $DRYRUN; then
- echo "$dump"
- else
- sum=$(echo "${line}" | sha1sum | awk '{print $1;}')
- cachefile="${CACHEDIR}/${sum}"
+ if [ $? -ne 0 ]; then
+ continue
+ fi
- if [ -f "$cachefile" ]; then
- echo "$dump" | diff -u \
- --label "local copy from $(/usr/bin/stat --printf='%y' ${cachefile})" "$cachefile" \
- --label "${url}" - \
- || echo
- fi
+ if [ "${filter}" != "" ]; then
+ dump=$(echo "${dump}" | eval "${filter}")
+ fi
- echo "$dump" > "$cachefile"
+ if $DRYRUN; then
+ echo "$dump"
+ else
+ sum=$(echo "${line}" | sha1sum | awk '{print $1;}')
+ cachefile="${CACHEDIR}/${sum}"
+
+ if [ -f "$cachefile" ]; then
+ echo "$dump" | diff -u \
+ --label "local copy from $(/usr/bin/stat --printf='%y' ${cachefile})" "$cachefile" \
+ --label "${url}" - \
+ || echo
fi
+
+ echo "$dump" > "$cachefile"
fi
- done < "${CONFIGFILE}"
+ done
}
collectGarbage() {
for cacheEntry in "${CACHEDIR}/"*; do
cacheSum=$(basename "$cacheEntry")
- while read configEntry; do
- if echo "${configEntry}" | grep -q -v '^#'; then
- configSum=$(echo "$configEntry" | sha1sum | awk '{print $1;}')
+ grep -v '^#' "${CONFIGFILE}" | while read configEntry; do
+ configSum=$(echo "$configEntry" | sha1sum | awk '{print $1;}')
- if [ "$cacheSum" == "$configSum" ]; then
- continue 2
- fi
+ if [ "$cacheSum" == "$configSum" ]; then
+ continue 2
fi
- done < "${CONFIGFILE}"
+ done
rm -f $cacheEntry
done