ctdb-scripts: Fix a bug in counter checking
authorMartin Schwenke <martin@meltin.net>
Tue, 5 Jul 2016 10:09:12 +0000 (20:09 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 21 Jul 2016 00:24:25 +0000 (02:24 +0200)
If there are insufficient arguments then they can't be shifted.

This function will be removed shortly.  However, it needs to work for
now as tests will be added that depend on it to work.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/functions

index 64b7c012d90adca8b7a4371f1518a48501e125bc..8f0b790983c8ee3c8f0b9d0102dc97abb34f4e1e 100755 (executable)
@@ -769,7 +769,11 @@ ctdb_check_counter () {
     _msg="${1:-error}"  # "error"  - anything else is silent on fail
     _op="${2:--ge}"  # an integer operator supported by test
     _limit="${3:-${service_fail_limit}}"
-    shift 3
+    if [ $# -le 3 ] ; then
+           shift $#
+    else
+           shift 3
+    fi
 
     _size=$(ctdb_counter_get "$1")