ctdb-tests: Avoid shellcheck warnings
authorMartin Schwenke <martin@meltin.net>
Thu, 5 Sep 2019 23:01:36 +0000 (09:01 +1000)
committerAmitay Isaacs <amitay@samba.org>
Tue, 17 Sep 2019 04:35:26 +0000 (04:35 +0000)
SC2086 Double quote to prevent globbing and word splitting

This one doesn't need the double quotes if it is contained within the
preceding variable expansion.

SC2181 Check exit code directly with e.g. 'if mycmd;', not indirectly with $?
SC2004 $/${} is unnecessary on arithmetic variables

These are straightforward.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/simple/scripts/local_daemons.bash

index 5da900288b29c55681814a27251ec343e77b771e..7bba0c32333caa11e94478a2e95bd4e6f100e0ae 100644 (file)
@@ -36,13 +36,15 @@ setup_ctdb ()
                ${public_addresses:+-P} ${public_addresses} \
                ${CTDB_USE_IPV6:+-6} \
                ${reclock_use_command:+-R} \
                ${public_addresses:+-P} ${public_addresses} \
                ${CTDB_USE_IPV6:+-6} \
                ${reclock_use_command:+-R} \
-               ${TEST_SOCKET_WRAPPER_SO_PATH:+-S} ${TEST_SOCKET_WRAPPER_SO_PATH}
+               ${TEST_SOCKET_WRAPPER_SO_PATH:+-S ${TEST_SOCKET_WRAPPER_SO_PATH}}
+       # Burying the above in an if-statement condition reduces readability.
+       # shellcheck disable=SC2181
        if [ $? -ne 0 ] ; then
                exit 1
        fi
 
        local pnn
        if [ $? -ne 0 ] ; then
                exit 1
        fi
 
        local pnn
-       for pnn in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
+       for pnn in $(seq 0 $((TEST_LOCAL_DAEMONS - 1))) ; do
                if $no_event_scripts ; then
                        rm -vf "${CTDB_BASE}/events/legacy/"*
                fi
                if $no_event_scripts ; then
                        rm -vf "${CTDB_BASE}/events/legacy/"*
                fi