@@ -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
6263Current configuration file: $CONFIG
@@ -73,7 +74,9 @@ Check mode is ment to be used from scripts to test if peers are
7374in 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
9194function fatal() {
9295 info --${FUNCNAME[0]} " $@ "
93- exit 1
96+ exit 2
9497}
9598
9699function error() {
@@ -322,6 +325,7 @@ argv=( "$@" )
322325XDEBUG=
323326DIFF=
324327CHECK=
328+ QUIET=0
325329
326330while (( $# > 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 ;;
348353includes+=( " $@ " )
349354
350355[[ -n $XDEBUG ]] && set -x
356+ (( QUIET >= 1 )) && exec 1> /dev/null
357+ (( QUIET >= 2 )) && exec 2> /dev/null
351358
352359trap 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
420427fi
421428exit " $retval "
0 commit comments