summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorshane.xb.qian <shane.qian@foxmail.com>2022-11-16 11:14:25 +0800
committershane.xb.qian <shane.qian@foxmail.com>2022-11-17 09:24:49 +0800
commitf6b5806af9489d4663b849b4360e314b0709d856 (patch)
treeb1d180bc268b9fe4eab5de03646408e501c7f281 /bin
parenteb69a8891da12273ac1f892c5b17ce274602eae6 (diff)
fix: make o and O macro work and really sync multiple/individual accounts
Signed-off-by: shane.xb.qian <shane.qian@foxmail.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/mailsync19
1 files changed, 15 insertions, 4 deletions
diff --git a/bin/mailsync b/bin/mailsync
index 1855ded..26e71ea 100755
--- a/bin/mailsync
+++ b/bin/mailsync
@@ -77,16 +77,27 @@ if [ "$#" -gt "0" ]; then
done
accounts=$*
fi
-# TODO handle account passed from argument
-[ -z "$accounts" ] && accounts="$(awk '/^Channel/ {print $2}' "$MBSYNCRC" 2>/dev/null)"
-[ -z "$pop_accounts" ] && [ -x $MPOPRC ] && pop_accounts="$(awk '/^account/ {print $2}' "$MPOPRC" 2>/dev/null)"
+[ -z "$imap_accounts" ] && [ -r "$MBSYNCRC" ] && imap_accounts="$(awk '/^Channel/ {print $2}' "$MBSYNCRC" 2>/dev/null)"
+[ -z "$pop_accounts" ] && [ -r "$MPOPRC" ] && pop_accounts="$(awk '/^account/ {print $2}' "$MPOPRC" 2>/dev/null)"
# Parallelize multiple accounts
-for account in $accounts; do
+for account in $imap_accounts; do
+ if [ -n "$accounts" ]; then
+ for tmp_ac in $accounts; do
+ [ "$tmp_ac" = "$account" ] && syncandnotify "imap" &
+ done
+ continue
+ fi
syncandnotify "imap" &
done
for account in $pop_accounts; do
+ if [ -n "$accounts" ]; then
+ for tmp_ac in $accounts; do
+ [ "$tmp_ac" = "$account" ] && syncandnotify "pop" &
+ done
+ continue
+ fi
syncandnotify "pop" &
done