ctdb-tests: Use portable wc -c instead of stat -c "%s"
authorAmitay Isaacs <amitay@gmail.com>
Thu, 19 Jul 2018 05:27:51 +0000 (15:27 +1000)
committerMartin Schwenke <martins@samba.org>
Sat, 28 Jul 2018 01:50:11 +0000 (03:50 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520

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

index 5cc995adf3fea7b6997560417383c4d252824c3b..09b32097e01218da3bbc9c47d43430d6830e5849 100755 (executable)
@@ -750,7 +750,10 @@ ctdb_counter_incr () {
 ctdb_counter_get () {
     _ctdb_counter_common "$1"
     # unary counting!
-    stat -c "%s" "$_counter_file" 2>/dev/null || echo 0
+    _val=$(wc -c < "$_counter_file" 2>/dev/null || echo 0)
+    # Strip leading spaces from ouput of wc (on freebsd)
+    # shellcheck disable=SC2086
+    echo $_val
 }
 
 ########################################################