diff --git a/NEWS b/NEWS index 0331fee..a1857c7 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,8 @@ Added support for mirroring deletions more accurately. Added --dry-run option. +Added --ext-exit option. + [1.4.0] The 'isync' compatibility wrapper was removed. diff --git a/TODO b/TODO index 10bd61f..dacdeb4 100644 --- a/TODO +++ b/TODO @@ -25,8 +25,6 @@ add alternative treatments of expired messages. ExpiredMessageMode: Prune separate folder - ArchiveSuffix, default .archive). add support for event notification callbacks. -it would be also possible to report more differentiated exit codes, but -that seems too limiting in the general case. make it possible to have different mailbox names for far and near side in Patterns. diff --git a/src/common.h b/src/common.h index 8e613f9..940e74d 100644 --- a/src/common.h +++ b/src/common.h @@ -115,6 +115,8 @@ BIT_ENUM( DRYRUN, + EXT_EXIT, + ZERODELAY, KEEPJOURNAL, FORCEJOURNAL, diff --git a/src/main.c b/src/main.c index 0efd7b8..7cfea1a 100644 --- a/src/main.c +++ b/src/main.c @@ -47,6 +47,7 @@ PACKAGE " " VERSION " - mailbox synchronizer\n" " -c, --config CONFIG read an alternate config file (default: ~/." EXE "rc)\n" " -D, --debug debugging modes (see manual)\n" " -y, --dry-run do not actually modify anything\n" +" -e, --ext-exit return extended exit code\n" " -V, --verbose display what is happening\n" " -q, --quiet don't display progress counters\n" " -v, --version display version\n" @@ -221,6 +222,8 @@ main( int argc, char **argv ) DFlags |= op; } else if (!strcmp( opt, "dry-run" )) { DFlags |= DRYRUN; + } else if (!strcmp( opt, "ext-exit" )) { + DFlags |= EXT_EXIT; } else if (!strcmp( opt, "pull" )) { cops |= XOP_PULL, mvars->ops[F] |= XOP_HAVE_TYPE; } else if (!strcmp( opt, "push" )) { @@ -461,6 +464,9 @@ main( int argc, char **argv ) case 'y': DFlags |= DRYRUN; break; + case 'e': + DFlags |= EXT_EXIT; + break; case 'T': for (; *ochar; ) { switch (*ochar++) { diff --git a/src/main_sync.c b/src/main_sync.c index 07b2883..9c38d20 100644 --- a/src/main_sync.c +++ b/src/main_sync.c @@ -388,6 +388,11 @@ sync_chans( core_vars_t *cvars, char **argv ) if (!cvars->list) { flushn(); summary(); + if (DFlags & EXT_EXIT) { + for (int t = 0; t < 2; t++) + if (new_done[t] || flags_done[t] || trash_done[t] || expunge_done[t]) + cvars->ret |= 32 << t; + } } } diff --git a/src/mbsync.1 b/src/mbsync.1 index 6014134..b218011 100644 --- a/src/mbsync.1 +++ b/src/mbsync.1 @@ -79,6 +79,12 @@ Enter simulation mode: the Channel status is queried and all required operations are determined, but no modifications are actually made to either the mailboxes or the state files. .TP +\fB-e\fR, \fB--ext-exit\fR +Return an extended exit code: Add 32 resp. 64 to the code if any +modifications were made on the far resp. near side. +An error may be reported at the same time, so the code may be for example +65 if some changes were successfully pulled, while others failed. +.TP \fB-V\fR, \fB--verbose\fR Enable \fIverbose\fR mode, which displays what is currently happening. .TP diff --git a/src/sync.c b/src/sync.c index 0dd6c9e..a588ae3 100644 --- a/src/sync.c +++ b/src/sync.c @@ -1776,7 +1776,7 @@ sync_close( sync_vars_t *svars, int t ) if ((svars->chan->ops[t] & (OP_EXPUNGE | OP_EXPUNGE_SOLO)) && !(DFlags & FAKEEXPUNGE) /*&& !(svars->state[t] & ST_TRASH_BAD)*/) { - if (Verbosity >= TERSE) { + if (Verbosity >= TERSE || (DFlags & EXT_EXIT)) { if (svars->opts[t] & OPEN_UID_EXPUNGE) { for (message_t *tmsg = svars->msgs[t]; tmsg; tmsg = tmsg->next) { if (tmsg->status & M_DEAD)