From: Samir Benmendil Date: Wed, 31 Aug 2022 21:36:08 +0000 (+0100) Subject: mbsync: only execute pre/post scripts if folders exists X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/dad0671fed50e93ad089afc307fe9ccdac04876a?ds=sidebyside mbsync: only execute pre/post scripts if folders exists Silences a bunch of regular warnings in logs. --- diff --git a/mbsync/sync-mail b/mbsync/sync-mail index e9cf8d9..6ea0e42 100755 --- a/mbsync/sync-mail +++ b/mbsync/sync-mail @@ -5,15 +5,21 @@ mbsync_args="$*" export dir="$(dirname "${BASH_SOURCE[0]}")" export config=$dir/config -for hook in $(find $dir/pre-sync.d -type f -name '*.hook' -executable); do - "$hook" $mbsync_args -done +pre_sync_dir=$dir/pre-sync.d +if [[ -d "$pre_sync_dir" ]]; then + for hook in $(find $pre_sync_dir -type f -name '*.hook' -executable); do + "$hook" $mbsync_args + done +fi mbsync -c "$config" $mbsync_args export mbsync_errno=$? -for hook in $(find $dir/post-sync.d -type f -name '*.hook' -executable); do - "$hook" $mbsync_args -done +post_sync_dir=$dir/post-sync.d +if [[ -d "$post_sync_dir" ]]; then + for hook in $(find $post_sync_dir -type f -name '*.hook' -executable); do + "$hook" $mbsync_args + done +fi exit $mbsync_errno