summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-06-03 09:05:17 +0200
committerPierre Schmitz <pierre@archlinux.de>2010-06-03 09:05:17 +0200
commit2de4630b5785ca0d8317233416afc15d7b1c1522 (patch)
tree9169b544b09eca944cf4f2866ec37dc4ece852bf
parentcd3eb840ba0571e45af9d63afac20c9873ae6aa3 (diff)
downloadw3watch-2de4630b5785ca0d8317233416afc15d7b1c1522.tar.gz
w3watch-2de4630b5785ca0d8317233416afc15d7b1c1522.tar.xz
Read complete config file even if there is no new line at the end
-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