]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add retry_quiet() function to retry quietly for an event to occur
authorOndřej Surý <ondrej@isc.org>
Wed, 20 Nov 2019 16:05:58 +0000 (00:05 +0800)
committerOndřej Surý <ondrej@isc.org>
Tue, 26 Nov 2019 08:21:39 +0000 (09:21 +0100)
(cherry picked from commit 31264a7e003d89581c7110cb0055e22bc69e1653)

bin/tests/system/conf.sh.in

index dad85d05eb89ab658ed475759b484bc22bba1aa4..60c8f68edfd5544680b345066f38a3d07a501a9a 100644 (file)
@@ -357,9 +357,9 @@ nextpart () {
         END          { print NR > "/dev/stderr" }' $1 2> $1.prev
 }
 
-# retry: keep running a command until it succeeds, up to $1 times, with
-# one-second intervals
-retry() {
+# _retry: keep running a command until it succeeds, up to $1 times, with
+# one-second intervals, optionally printing a message upon every attempt
+_retry() {
        __retries="${1}"
        shift
 
@@ -369,7 +369,9 @@ retry() {
                fi
                __retries=$((__retries-1))
                if [ "${__retries}" -gt 0 ]; then
-                       echo_i "retrying"
+                       if [ "${__retry_quiet}" -ne 1 ]; then
+                               echo_i "retrying"
+                       fi
                        sleep 1
                else
                        return 1
@@ -377,6 +379,18 @@ retry() {
        done
 }
 
+# retry: call _retry() in verbose mode
+retry() {
+       __retry_quiet=0
+       _retry "$@"
+}
+
+# retry_quiet: call _retry() in silent mode
+retry_quiet() {
+       __retry_quiet=1
+       _retry "$@"
+}
+
 # rndc_dumpdb: call "rndc dumpdb [...]" and wait until it completes
 #
 # The first argument is the name server instance to send the command to, in the