diff options
author | David Runge <dave@sleepmap.de> | 2021-02-20 10:46:02 +0100 |
---|---|---|
committer | David Runge <dave@sleepmap.de> | 2021-02-20 10:46:02 +0100 |
commit | a61cefe80c544632bbdd8bddfb336e331816bf49 (patch) | |
tree | 00e229e00bb66b52f2e6008abc486ad0440636cd | |
parent | 97f7a6fbb6cd6dd16005df12df40893884305ccd (diff) | |
download | dotfiles-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).
-rwxr-xr-x | bin/mbsync2mutt_mailboxes | 7 |
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 |