aboutsummaryrefslogtreecommitdiffstats
path: root/bin/mbsync2mutt_mailboxes
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2021-02-20 10:46:02 +0100
committerDavid Runge <dave@sleepmap.de>2021-02-20 10:46:02 +0100
commita61cefe80c544632bbdd8bddfb336e331816bf49 (patch)
tree00e229e00bb66b52f2e6008abc486ad0440636cd /bin/mbsync2mutt_mailboxes
parent97f7a6fbb6cd6dd16005df12df40893884305ccd (diff)
downloaddotfiles-a61cefe80c544632bbdd8bddfb336e331816bf49.tar.gz
dotfiles-a61cefe80c544632bbdd8bddfb336e331816bf49.tar.bz2
dotfiles-a61cefe80c544632bbdd8bddfb336e331816bf49.tar.xz
dotfiles-a61cefe80c544632bbdd8bddfb336e331816bf49.zip
mbsync/mutt: Guard against empty mailbox file
bin/mbsync2mutt_mailboxes: Change script to only copy the temporary mailboxes.rc file in place if at least one account entry is found (prevents override of existing data with an empty file, if mbsync returns nothing due to locked secret).
Diffstat (limited to 'bin/mbsync2mutt_mailboxes')
-rwxr-xr-xbin/mbsync2mutt_mailboxes7
1 files changed, 6 insertions, 1 deletions
diff --git a/bin/mbsync2mutt_mailboxes b/bin/mbsync2mutt_mailboxes
index c98e219..ccf9505 100755
--- a/bin/mbsync2mutt_mailboxes
+++ b/bin/mbsync2mutt_mailboxes
@@ -27,11 +27,16 @@ get_mailboxes_by_account() {
}
output_mailboxes_to_file() {
+ local tmpfile counter
tmpfile="$(mktemp)"
+ counter=0
for account in "${!mailboxes[@]}"; do
echo -e "mailboxes ${mailboxes[$account]}\n" >> "$tmpfile"
+ counter=$(( "$counter" + 1 ))
done
- mv "$tmpfile" "$output_file"
+ if (( "$counter" > 0 )); then
+ mv "$tmpfile" "$output_file"
+ fi
}
if [ $# -ne 1 ]; then