commit 7354cd87e2a1a0a6e6085b47d77c258bc692feb2
parent d201bca9d8bb0a67ac2f611f74d2b993f2286b82
Author: Jaromil <jaromil@dyne.org>
Date: Mon, 5 May 2014 20:55:59 +0200
more fixes for whitespace paths
Diffstat:
3 files changed, 79 insertions(+), 84 deletions(-)
diff --git a/src/zlibs/filters b/src/zlibs/filters
@@ -168,15 +168,15 @@ require "fileinto";
# blacklist
if header :contains "From" [
EOF
- newlock $TMPDIR/blacklist.sieve.$id
+ newlock "$TMPDIR/blacklist.sieve.$id"
cat <<EOF | ${SQL} -batch ${addressbook} \
- >> $TMPDIR/blacklist.sieve.$id
+ >> "$TMPDIR/blacklist.sieve.$id"
SELECT email FROM blacklist;
EOF
typeset -alU blacklist
- for i in `cat $TMPDIR/blacklist.sieve.$id`; do
- blacklist+=($i); done
- unlink $TMPDIR/blacklist.sieve.$id
+ for i in `cat "$TMPDIR/blacklist.sieve.$id"`; do
+ blacklist+=("$i"); done
+ unlink "$TMPDIR/blacklist.sieve.$id"
c=${#blacklist}
for b in $blacklist; do
print -n "\"$b\"" >> "$MAILDIRS/Filters.sieve"
@@ -244,7 +244,7 @@ EOF
#######
act "compiling rules for mailinglists"
- print "# filters generated from Filters.txt" >> $PROCMAILDIR/rc
+ print "# filters generated from Filters.txt" >> "$PROCMAILDIR/rc"
typeset -alU filter_from
typeset -alU filter_to
@@ -333,17 +333,17 @@ cat <<EOF >> "$MAILDIRS/Filters.sieve"
if header :contains "From" [
EOF
-newlock $TMPDIR/whitelist.sieve.$id
+newlock "$TMPDIR/whitelist.sieve.$id"
cat <<EOF | ${SQL} -batch ${addressbook} \
- >> $TMPDIR/whitelist.sieve.$id
+ >> "$TMPDIR/whitelist.sieve.$id"
SELECT email FROM whitelist;
EOF
typeset -alU whitelist
-for i in `cat $TMPDIR/whitelist.sieve.$id`; do
- whitelist+=($i); done
+for i in `cat "$TMPDIR/whitelist.sieve.$id"`; do
+ whitelist+=("$i"); done
-unlink $TMPDIR/whitelist.sieve.$id
+unlink "$TMPDIR/whitelist.sieve.$id"
c=${#whitelist}
for w in $whitelist; do
@@ -366,7 +366,7 @@ EOF
#### PROCMAIL
- cat <<EOF >> $PROCMAILDIR/rc
+ cat <<EOF >> "$PROCMAILDIR/rc"
}
:0
@@ -388,7 +388,7 @@ zz.spam/
EOF
#######
- cat <<EOF >> $PROCMAILDIR/rc
+ cat <<EOF >> "$PROCMAILDIR/rc"
# filters generated from Accounts
:0
* ? test \$PMSRC/pf-chkto.rc
@@ -399,18 +399,19 @@ EOF
if header :contains "To" [
EOF
typeset -alU recv
- for f in `${=find} $MAILDIRS/Accounts/ -type f | grep -v 'smtp'`; do
- for addr in `cat $f | awk '
+ accts=`${=find} "$MAILDIRS/Accounts/" -type f | grep -v 'smtp'`
+ for f in ${(f)accts}; do
+ for addr in `cat "$f" | awk '
/^email/ { print $2 }
/^alias/ { print $2 }
- '`; do func "email $addr in `basename $f`"; recv+=($addr); done
+ '`; do func "email $addr in `basename $f`"; recv+=("$addr"); done
done
c=${#recv}
for rr in ${recv}; do \
# procmail
print "ADDR=${rr}\tDEST=priv/\tINCLUDERC=\$PMSRC/pf-chkto.rc" \
- >> $PROCMAILDIR/rc
+ >> "$PROCMAILDIR/rc"
# sieve
print -n "\"${rr}\"" >> "$MAILDIRS/Filters.sieve"
@@ -427,7 +428,7 @@ EOF
EOF
- cat <<EOF >> $PROCMAILDIR/rc
+ cat <<EOF >> "$PROCMAILDIR/rc"
}
:0
@@ -444,15 +445,15 @@ unsorted.ml/
EOF
# MUTT (generate mailboxes priority this parser)
- print " \\" >> $MUTTDIR/mboxes
- print " +unsorted.ml +unsorted" >> $MUTTDIR/mboxes
+ print " \\" >> "$MUTTDIR/mboxes"
+ print " +unsorted.ml +unsorted" >> "$MUTTDIR/mboxes"
- uniq $MUTTDIR/mboxes > $TMPDIR/mboxes
- mv $TMPDIR/mboxes $MUTTDIR/mboxes
- rm -f $TMPDIR/mboxes
+ uniq "$MUTTDIR/mboxes" > "$TMPDIR/mboxes"
+ mv "$TMPDIR/mboxes" "$MUTTDIR/mboxes"
+ rm -f "$TMPDIR/mboxes"
# conclude procmail
- cat <<EOF >> $PROCMAILDIR/rc
+ cat <<EOF >> "$PROCMAILDIR/rc"
# if got here, go to unsorted
:0:
diff --git a/src/zlibs/init b/src/zlibs/init
@@ -23,56 +23,56 @@
maildir_init() {
# source functions
- source $WORKDIR/jaro source
+ source "$WORKDIR/jaro" source
notice "Initializing current directory for Jaro Mail"
- MAILDIRS=${1}
- ${=mkdir} $MAILDIRS/tmp $MAILDIRS/cache
+ MAILDIRS="${1}"
+ ${=mkdir} "$MAILDIRS/tmp" "$MAILDIRS/cache"
# copy defaults if missing
- if ! [ -r $MAILDIRS/Filters.txt ]; then
- cp -v $WORKDIR/Filters.txt $MAILDIRS/Filters.txt
+ if ! [ -r "$MAILDIRS/Filters.txt" ]; then
+ cp -v "$WORKDIR/Filters.txt" "$MAILDIRS/Filters.txt"
act "Default filters created"
else
error "Existing configuration $MAILDIRS/Filters.txt skipped"
fi
- if ! [ -r $MAILDIRS/Applications.txt ]; then
- cp -v $WORKDIR/Applications.txt $MAILDIRS/Applications.txt
+ if ! [ -r "$MAILDIRS/Applications.txt" ]; then
+ cp -v "$WORKDIR/Applications.txt" "$MAILDIRS/Applications.txt"
act "Default helper applications settings created"
else
error "Existing configuration $MAILDIRS/Applications.txt skipped"
fi
- if ! [ -r $MAILDIRS/Mutt.txt ]; then
- cp -v $WORKDIR/Mutt.txt $MAILDIRS/Mutt.txt
+ if ! [ -r "$MAILDIRS/Mutt.txt" ]; then
+ cp -v "$WORKDIR/Mutt.txt" "$MAILDIRS/Mutt.txt"
act "Default Mutt configuration template created"
else
error "Existing configuration $MAILDIRS/Mutt.txt skipped"
fi
- if ! [ -r $MAILDIRS/Accounts ]; then
- cp -v -r $WORKDIR/Accounts $MAILDIRS/Accounts
+ if ! [ -r "$MAILDIRS/Accounts" ]; then
+ cp -v -r "$WORKDIR/Accounts" "$MAILDIRS/Accounts"
act "Default accounts directory created"
else
error "Existing configuration $MAILDIRS/Accounts skipped"
fi
- { test -r $MAILDIRS/Manual.pdf } || {
- cp -f $WORKDIR/jaromail-manual.pdf $MAILDIRS/Manual.pdf }
+ { test -r "$MAILDIRS/Manual.pdf" } || {
+ cp -f "$WORKDIR/jaromail-manual.pdf" "$MAILDIRS/Manual.pdf" }
# update the settings
- JAROMAILDIR=$MAILDIRS JAROWORKDIR=$WORKDIR $WORKDIR/jaro update -q
+ JAROMAILDIR="$MAILDIRS" JAROWORKDIR="$WORKDIR" "$WORKDIR/jaro" update -q
# create a startup wrapper
- cat <<EOF > $MAILDIRS/jaro
+ cat <<EOF > "$MAILDIRS/jaro"
#!/usr/bin/env zsh
-export JAROWORKDIR=${WORKDIR}
-export JAROMAILDIR=${MAILDIRS}
-${WORKDIR}/jaro \${=@}
+export JAROWORKDIR="${WORKDIR}"
+export JAROMAILDIR="${MAILDIRS}"
+"${WORKDIR}/jaro" \${=@}
EOF
- chmod +x $MAILDIRS/jaro
+ chmod +x "$MAILDIRS/jaro"
-}-
\ No newline at end of file
+}
diff --git a/src/zlibs/maildirs b/src/zlibs/maildirs
@@ -70,19 +70,14 @@ maildirmake() {
# fills up all maildirs array
list_maildirs() {
- maildirs=()
- for m in `${=find} $MAILDIRS/* -maxdepth 1 -type d | awk '
- /cur$/ {next}
- /tmp$/ {next}
- /new$/ {next}
- /\/jaro\// {next}
- {print $0}'`; do
-
- { maildircheck $m } && {
+ maildirs=`${=find} "$MAILDIRS" -maxdepth 1 -type d`
+ for m in ${(f)maildirs}; do
+ func "$m"
+ { maildircheck "$m" } && {
# is a maildir
- { test "`${=find} $m -type f`" != "" } && {
+ { test "`${=find} "$m" -type f`" != "" } && {
# and is not empty
- maildirs+=(`basename $m`)
+ maildirs+=(`basename "$m"`)
}
}
done
@@ -93,7 +88,7 @@ maildirs_lastlog() {
# returns an array of destinations maildirs touched by the last filtering operation
# based on the procmail log format
typeset -alU dests prio lasts
- _folders="`cat ${MAILDIRS}/logs/procmail.log|awk '/Folder:/ {print $2}' | cut -d/ -f1`"
+ _folders=`cat "${MAILDIRS}/logs/procmail.log"|awk '/Folder:/ {print $2}' | cut -d/ -f1`
for d in ${(f)_folders}; do
func "maildir touched by last operation: $d"
# skip procmail glitch
@@ -138,21 +133,21 @@ rmdupes() {
error "Directory not found: $folder"
continue }
- { maildircheck ${folder} } || {
+ { maildircheck "${folder}" } || {
error "Not a maildir folder: $folder"
continue }
c=0
notice "Checking for duplicates in folder: `basename $folder`"
msgs=()
- for m in `${=find} ${folder} -type f`; do
- msgs+=($m)
+ for m in `${=find} "${folder}" -type f`; do
+ msgs+=("$m")
done
act "${#msgs} messages to check"
for m in ${=msgs}; do
# 128MB should be enough ehre?
- formail -D 128000000 $formail_cache <$m \
- && rm $m && c=$(( $c + 1 ))
+ formail -D 128000000 $formail_cache <"$m" \
+ && rm "$m" && c=$(( $c + 1 ))
done
act "$c duplicates found and deleted"
tot=$(( $tot + $c ))
@@ -173,32 +168,32 @@ merge() {
error "Cannot merge same directory in itself: $src = $dst"
return 1 }
- { maildircheck $src } || {
+ { maildircheck "$src" } || {
error "Source is not a maildir: $src"
return 1 }
- { maildircheck $dst } || {
+ { maildircheck "$dst" } || {
error "Destination is not a maildir: $dst"
return 1 }
notice "Merging maildir ${src} into ${dst}"
c=0
- for i in `${=find} ${src}/cur -type f`; do
- mv $i ${dst}/cur/; c=$(($c + 1))
+ for i in `${=find} "${src}/cur" -type f`; do
+ mv $i "${dst}/cur/"; c=$(($c + 1))
{ test $? = 0 } || {
error "error moving file: $i"
error "merge aborted."
return 1 }
done
- for i in `${=find} ${src}/new -type f`; do
- mv $i ${dst}/new/; c=$(($c + 1))
+ for i in `${=find} "${src}/new" -type f`; do
+ mv $i "${dst}/new/"; c=$(($c + 1))
{ test $? = 0 } || {
error "error moving file: $i"
error "merge aborted."
return 1 }
done
- for i in `${=find} ${src}/tmp -type f`; do
- mv $i ${dst}/tmp/; c=$(($c + 1))
+ for i in `${=find} "${src}/tmp" -type f`; do
+ mv $i "${dst}/tmp/"; c=$(($c + 1))
{ test $? = 0 } || {
error "error moving file: $i"
error "merge aborted."
@@ -206,12 +201,12 @@ merge() {
done
notice "$c mails succesfully moved"
act "Removing source directory ${src}"
- ${=rm} -r ${src}
+ ${=rm} -r "${src}"
act "Purging duplicates in destination"
- formail_cache=$TMPDIR/filter.rmdupes.$datestamp.$RANDOM
- newlock $formail_cache
- rmdupes ${dst}
- unlock $formail_cache
+ formail_cache="$TMPDIR/filter.rmdupes.$datestamp.$RANDOM"
+ newlock "$formail_cache"
+ rmdupes "${dst}"
+ unlock "$formail_cache"
act "Done. All mails merged into ${dst}"
}
@@ -230,7 +225,7 @@ filter() {
unlock "$MAILDIRS/logs/procmail-${datestamp}.log"
}
- prc=$PROCMAILDIR/rc
+ prc="$PROCMAILDIR/rc"
typeset -al fall
@@ -240,13 +235,13 @@ filter() {
error "Directory not found: $folder"
continue }
- { maildircheck ${folder} } || {
+ { maildircheck "$folder" } || {
error "Not a maildir folder: $folder"
continue }
notice "Filtering folder $folder"
# first index current state
- for m in `${=find} $folder -type f`; do fall+=($m); done
+ for m in `${=find} "$folder" -type f`; do fall+=("$m"); done
done
{ test ${#fall} = 0 } && {
@@ -257,22 +252,22 @@ filter() {
# then process it, this way ignoring new mails send to same folder
act "Filtering ${#fall} messages..."
for n in ${=fall}; do
- cat $n | procmail -m $prc
+ cat "$n" | procmail -m "$prc"
done
notice "Done filtering"
unset fall
- total=`mailstat -k $MAILDIRS/logs/procmail.log | tail -n1 | awk '{print $2}'`
- briefing=`mailstat -kt $MAILDIRS/logs/procmail.log |awk '!/procmail/ { print " " $2 "\t" $3 }'|sort -nr`
+ total=`mailstat -k "$MAILDIRS/logs/procmail.log" | tail -n1 | awk '{print $2}'`
+ briefing=`mailstat -kt "$MAILDIRS/logs/procmail.log" |awk '!/procmail/ { print " " $2 "\t" $3 }'|sort -nr`
echo "${briefing}"
- formail_cache=$TMPDIR/filter.rmdupes.$datestamp.$RANDOM
- newlock $formail_cache
+ formail_cache="$TMPDIR/filter.rmdupes.$datestamp.$RANDOM"
+ newlock "$formail_cache"
# prunes out all duplicates from last filtered mails,
rmdupes lastlog
- unlink $formail_cache
+ unlink "$formail_cache"
}