Skip to content

Commit 07de2fb

Browse files
committed
MINOR: zsync: Add quiet option normally ment to be used with check mode
1 parent 2f235fc commit 07de2fb

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

zsync/zsync

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Options:
5757
-i, --include Add include rule
5858
-e, --exclude Add exclude rule
5959
-t, --check Check mode, implies dry-run
60+
-q, --quiet Disable stdout, repeat for stderr
6061
-h, --help Display this help
6162
6263
Current configuration file: $CONFIG
@@ -73,7 +74,9 @@ Check mode is ment to be used from scripts to test if peers are
7374
in sync. In check mode, status codes are as follows:
7475
0: peers in sync
7576
1: peers out of sync
76-
2: error, sync status is undefined
77+
2: error, sync status is undefined or fatal error
78+
79+
Flag -q, --quiet is normally ment to be used with check mode.
7780
"
7881
exit "$status"
7982
}
@@ -90,7 +93,7 @@ function info() {
9093

9194
function fatal() {
9295
info --${FUNCNAME[0]} "$@"
93-
exit 1
96+
exit 2
9497
}
9598

9699
function error() {
@@ -322,6 +325,7 @@ argv=( "$@" )
322325
XDEBUG=
323326
DIFF=
324327
CHECK=
328+
QUIET=0
325329

326330
while (( $# > 0 )); do
327331
case "$1" in
@@ -337,6 +341,7 @@ while (( $# > 0 )); do
337341
--do-rsync) do_remote_rsync "${@:2}"; exit $? ;;
338342
--do-keyscan) keyscan=1 ;;
339343
--x-debug) XDEBUG=1 ;;
344+
-q|--quiet) (( QUIET++ )) ;;
340345
-h|--help) exit_usage ;;
341346
--) shift; break ;;
342347
-*) exit_usage 1 ;;
@@ -348,6 +353,8 @@ done
348353
includes+=( "$@" )
349354

350355
[[ -n $XDEBUG ]] && set -x
356+
(( QUIET >= 1 )) && exec 1>/dev/null
357+
(( QUIET >= 2 )) && exec 2>/dev/null
351358

352359
trap on_exit EXIT
353360

@@ -415,7 +422,7 @@ if [[ -n $CHECK ]]; then
415422
case "$retval,${#CHECK_OUT_OF_SYNC[@]}" in
416423
0,0) exit 0 ;;
417424
0,*) exit 1 ;;
418-
*) exit 2 ;;
425+
*) exit 2 ;; # same as fatal
419426
esac
420427
fi
421428
exit "$retval"

0 commit comments

Comments
 (0)