aboutsummaryrefslogtreecommitdiff
path: root/scripts/dot-local/bin/mailsync
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/dot-local/bin/mailsync')
-rwxr-xr-xscripts/dot-local/bin/mailsync4
1 files changed, 3 insertions, 1 deletions
diff --git a/scripts/dot-local/bin/mailsync b/scripts/dot-local/bin/mailsync
index 7e16626..be2f93d 100755
--- a/scripts/dot-local/bin/mailsync
+++ b/scripts/dot-local/bin/mailsync
@@ -8,7 +8,7 @@ fi
mbsync_running()
{
- account_escaped=$(printf '%s\n' "$1" | sed 's/[.[\*^$()+?{|\\]/\\&/g')
+ local account_escaped=$(printf '%s\n' "$1" | sed 's/[.[\*^$()+?{|\\]/\\&/g')
pgrep -f "^mbsync([[:space:]]+[^ ]+)*[[:space:]]+$account_escaped($|[[:space:]])" >/dev/null ||
pgrep -f "^mbsync([[:space:]]+[^ ]+)*[[:space:]]+-a($|[[:space:]])" >/dev/null
@@ -53,6 +53,7 @@ sync_and_notify()
{
mbsync $mbsync_flag "$1"
+ local new newcount
new=$(fd --type f --changed-after "@$time_lastrun" . "$MAILDIR/$1/INBOX/new/" "$MAILDIR/$1/INBOX/cur/" 2>/dev/null)
newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l)
@@ -64,6 +65,7 @@ sync_and_notify()
$((newcount > 0)))
echo "$newcount new mail for $1."
for file in $new; do
+ local subject from
# Extract and decode subject and sender from mail.
subject=$(awk '/^Subject: / && ++n == 1,/^.*: / && ++i == 2' "$file" | head -n-1 |
perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' |