ctdb-tests: Avoid ShellCheck warning SC2059
authorMartin Schwenke <mschwenke@ddn.com>
Tue, 4 Jul 2023 00:30:05 +0000 (10:30 +1000)
committerMartin Schwenke <martins@samba.org>
Wed, 5 Jul 2023 11:18:37 +0000 (11:18 +0000)
  SC2059 (info): Don't use variables in the printf format string. Use printf '..%s..' "$foo".

Move the format string to the function and just parameterise the share
type.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
ctdb/tests/UNIT/eventscripts/50.samba.monitor.105.sh
ctdb/tests/UNIT/eventscripts/60.nfs.monitor.161.sh
ctdb/tests/UNIT/eventscripts/scripts/local.sh

index 1f2fa1e9068b03dcaa2d6bf1fc9514b39256f326..7208aca5eae4f1801000261bd3a4ee33852b59b9 100755 (executable)
@@ -6,7 +6,7 @@ define_test "non-existent share path"
 
 setup
 
-out=$(shares_missing "ERROR: samba directory \"%s\" not available" 2)
+out=$(shares_missing "samba" 2)
 
 required_result 1 "$out"
 simple_test
index ed080c2c4c839febaad8e7e1ae0a97a87175b2fe..1fa73bb8f91b5ca090a46ae972528d995f2ec15b 100755 (executable)
@@ -6,7 +6,7 @@ define_test "2nd share missing"
 
 setup
 
-out=$(shares_missing "ERROR: nfs directory \"%s\" not available" 2)
+out=$(shares_missing "nfs" 2)
 
 required_result 1 "$out"
 simple_test
index 72c43bd7ee76e1fe2e67bc9c6553078a6a6fa538..84d0f355218c36a1f04969a7e61579c4648bf56e 100644 (file)
@@ -171,7 +171,7 @@ setup_shares()
 shares_missing()
 {
        # Mark some shares as non-existent
-       _fmt="$1"
+       _type="$1"
        shift
 
        _out=""
@@ -187,7 +187,8 @@ shares_missing()
 
                        debug "Mark share $_n as missing share \"$_i\""
                        rmdir "$_i"
-                       _t=$(printf "$_fmt" "${_i}")
+                       _t=$(printf "ERROR: %s directory \"%s\" not available" \
+                                   "$_type" "${_i}")
                        _out="${_out}${_out:+${_nl}}${_t}"
                done
                _n=$(($_n + 1))