summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2019-03-07 15:40:59 +1100
committerAmitay Isaacs <amitay@samba.org>2019-03-15 05:17:14 +0000
commit6555fbce995d3d3a7b162ea49a4a9844e234fed8 (patch)
tree255d88f514518837ba407d2e16f7d8a2c63e5402 /ctdb
parent2fce893b2c8f63c72c5e0fb177ca61c93317b751 (diff)
downloadsamba-6555fbce995d3d3a7b162ea49a4a9844e234fed8.tar.gz
ctdb-tests: Shell cleanups in wait_until() function
This file is included by local_daemons.sh, which is not a bash script and wait_until() uses the "local" keyword. Prefixing variable names with '_' to indicate that they are local changes a lot of lines in this function. So, fix indentation, potential quoting problems and other ShellCheck hits while touching this function. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@samba.org>
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/tests/scripts/common.sh61
1 files changed, 30 insertions, 31 deletions
diff --git a/ctdb/tests/scripts/common.sh b/ctdb/tests/scripts/common.sh
index c1713fa1f89..b75fe066dcd 100644
--- a/ctdb/tests/scripts/common.sh
+++ b/ctdb/tests/scripts/common.sh
@@ -29,43 +29,42 @@ fi
# I is the recheck interval.
wait_until ()
{
- local timeout="$1" ; shift # "$@" is the command...
+ _timeout="$1" ; shift # "$@" is the command...
- local interval=1
- case "$timeout" in
+ _interval=1
+ case "$_timeout" in
*/*)
- interval="${timeout#*/}"
- timeout="${timeout%/*}"
- esac
-
- local negate=false
- if [ "$1" = "!" ] ; then
- negate=true
- shift
- fi
-
- echo -n "<${timeout}|"
- local t=$timeout
- while [ $t -gt 0 ] ; do
- local rc=0
- "$@" || rc=$?
- if { ! $negate && [ $rc -eq 0 ] ; } || \
- { $negate && [ $rc -ne 0 ] ; } ; then
- echo "|$(($timeout - $t))|"
- echo "OK"
- return 0
+ _interval="${_timeout#*/}"
+ _timeout="${_timeout%/*}"
+ esac
+
+ _negate=false
+ if [ "$1" = "!" ] ; then
+ _negate=true
+ shift
fi
- local i
- for i in $(seq 1 $interval) ; do
- echo -n .
+
+ printf '<%d|' "$_timeout"
+ _t="$_timeout"
+ while [ "$_t" -gt 0 ] ; do
+ _rc=0
+ "$@" || _rc=$?
+ if { ! $_negate && [ $_rc -eq 0 ] ; } || \
+ { $_negate && [ $_rc -ne 0 ] ; } ; then
+ echo "|$((_timeout - _t))|"
+ echo "OK"
+ return 0
+ fi
+ for _i in $(seq 1 "$_interval") ; do
+ printf '.'
+ done
+ _t=$((_t - _interval))
+ sleep "$_interval"
done
- t=$(($t - $interval))
- sleep $interval
- done
- echo "*TIMEOUT*"
+ echo "*TIMEOUT*"
- return 1
+ return 1
}
# setup_ctdb_base <parent> <subdir> [item-to-copy]...