Removed the compression of the archive.
authorFrancois Fleuret <francois@fleuret.org>
Mon, 22 Mar 2010 20:39:21 +0000 (21:39 +0100)
committerFrancois Fleuret <francois@fleuret.org>
Mon, 22 Mar 2010 20:39:21 +0000 (21:39 +0100)
gma.sh

diff --git a/gma.sh b/gma.sh
index ae7bdcd..6d25f0f 100755 (executable)
--- a/gma.sh
+++ b/gma.sh
@@ -35,11 +35,20 @@ if [[ $1 ]]; then
         exit 1
     fi
 
         exit 1
     fi
 
-    if [[ $2 ]]; then
-        FILE_PATTERN="${MAIL_ARCHIVE_DIR}/${2}/*/*gz"
-        SIZE=$(\dus ${MAIL_ARCHIVE_DIR}/${2} | cut -f 1 -d" ")
+    shift
+
+    HEADER_ONLY="-H"
+
+    if [[ $1 == "--body" ]]; then
+        HEADER_ONLY=""
+        shift
+    fi
+
+    if [[ $1 ]]; then
+        FILE_PATTERN="${MAIL_ARCHIVE_DIR}/${1}/*/*"
+        SIZE=$(\dus ${MAIL_ARCHIVE_DIR}/${1} | cut -f 1 -d" ")
     else
     else
-        FILE_PATTERN="${MAIL_ARCHIVE_DIR}/*/*/*gz"
+        FILE_PATTERN="${MAIL_ARCHIVE_DIR}/*/*/*"
         SIZE=$(\dus ${MAIL_ARCHIVE_DIR}/ | cut -f 1 -d" ")
     fi
 
         SIZE=$(\dus ${MAIL_ARCHIVE_DIR}/ | cut -f 1 -d" ")
     fi
 
@@ -49,9 +58,8 @@ if [[ $1 ]]; then
 
     cat ${FILE_PATTERN} \
         | pv -s ${SIZE} -p -t -e - \
 
     cat ${FILE_PATTERN} \
         | pv -s ${SIZE} -p -t -e - \
-        | zcat \
-        | mboxgrep -i "$1" \
-        | mboxgrep -v '^Subject:.*SPAM' > ${RESULT_MBOX}
+        | mboxgrep ${HEADER_ONLY} -i "${PATTERN}" \
+        | mboxgrep ${HEADER_ONLY} -v '^Subject:.*SPAM' > ${RESULT_MBOX}
     echo "Found "$(grep ^"From " ${RESULT_MBOX} | wc -l)" messages."
 
 else
     echo "Found "$(grep ^"From " ${RESULT_MBOX} | wc -l)" messages."
 
 else