fix forwarded emails and posix whitespace regex

This commit is contained in:
luukvbaal 2019-06-01 20:34:09 +02:00 committed by GitHub
parent e50d51d3e5
commit 7955090f9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,8 +29,8 @@ syncandnotify() {
notify "$acc" "$newcount" & notify "$acc" "$newcount" &
for file in $new; do for file in $new; do
# Extract subject and sender from mail. # Extract subject and sender from mail.
from=$(grep "^From: " "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; if ($NF>=3)$NF=""; print $0 }' | tr -d "\"\'\<\>" | sed 's/^ \(.*\) $/\1/') from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed 's/^[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//')
subject=$(sed -n '/^Subject: /,/^.*:/p' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | head -n-1) subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: /' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//')
notify-send "📧$from:" "$subject" & notify-send "📧$from:" "$subject" &
done done
fi fi