From: Martin Schwenke Date: Wed, 15 Mar 2023 06:56:40 +0000 (+1100) Subject: ctdb-scripts: Avoid errors for uninitialised counters X-Git-Tag: tevent-0.16.0~252 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4981984dd4794d0b8cb5b3cf434fc1d1ae183bfd;p=thirdparty%2Fsamba.git ctdb-scripts: Avoid errors for uninitialised counters Uninitialised counters are treated as 0, but still produce an error. The redirect to stderr needs to come before the redirect for a missing counter file. The seemingly saner alternative of moving it outside the subshell works when dash is /bin/sh (e.g. on Debian) but does not work when bash is /bin/sh (e.g. on Fedora). Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/config/functions b/ctdb/config/functions index 56105aab165..5a7737ec34a 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -754,7 +754,7 @@ ctdb_counter_get() { _ctdb_counter_common "$1" # unary counting! - _val=$(wc -c <"$_counter_file" 2>/dev/null || echo 0) + _val=$(wc -c 2>/dev/null <"$_counter_file" || echo 0) # Strip leading spaces from output of wc (on freebsd) # shellcheck disable=SC2086 echo $_val