diff --git a/ctdb/config/events/legacy/11.routing.script b/ctdb/config/events/legacy/11.routing.script index 018ee5732a6..3a526e1ed47 100755 --- a/ctdb/config/events/legacy/11.routing.script +++ b/ctdb/config/events/legacy/11.routing.script @@ -39,7 +39,7 @@ updateip) oiface=$2 niface=$3 while read iface dest gw; do - if [ "$niface" = "$iface" -o "$oiface" = "$iface" ] ; then + if [ "$niface" = "$iface" ] || [ "$oiface" = "$iface" ] ; then ip route add "$dest" via "$gw" dev "$iface" >/dev/null 2>&1 fi done <"${CTDB_BASE}/static-routes" diff --git a/ctdb/config/events/legacy/13.per_ip_routing.script b/ctdb/config/events/legacy/13.per_ip_routing.script index 269829483ab..ed5677327a1 100755 --- a/ctdb/config/events/legacy/13.per_ip_routing.script +++ b/ctdb/config/events/legacy/13.per_ip_routing.script @@ -20,8 +20,8 @@ table_id_prefix="ctdb." [ "$CTDB_PER_IP_ROUTING_TABLE_ID_LOW" -lt "$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" ] 2>/dev/null || \ die "error: CTDB_PER_IP_ROUTING_TABLE_ID_LOW[$CTDB_PER_IP_ROUTING_TABLE_ID_LOW] and/or CTDB_PER_IP_ROUTING_TABLE_ID_HIGH[$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH] improperly configured" -if [ "$CTDB_PER_IP_ROUTING_TABLE_ID_LOW" -le 253 -a \ - 255 -le "$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" ] ; then +if [ "$CTDB_PER_IP_ROUTING_TABLE_ID_LOW" -le 253 ] && \ + [ 255 -le "$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" ] ; then die "error: range CTDB_PER_IP_ROUTING_TABLE_ID_LOW[$CTDB_PER_IP_ROUTING_TABLE_ID_LOW]..CTDB_PER_IP_ROUTING_TABLE_ID_HIGH[$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH] must not include 253-255" fi @@ -49,7 +49,7 @@ ipv4_is_valid_addr() for _o in $(export IFS="." ; echo $_ip) ; do # The 2>/dev/null stops output from failures where an "octet" # is not numeric. The test will still fail. - if ! [ 0 -le $_o -a $_o -le 255 ] 2>/dev/null ; then + if ! [ 0 -le $_o ] && [ $_o -le 255 ] 2>/dev/null ; then return 1 fi _count=$((_count + 1)) @@ -149,8 +149,9 @@ ensure_table_id_for_ip () fi # Potentially update the new table id to be used. The # redirect stops error spam for a non-numeric value. - if [ "$_new" -le "$_t" -a \ - "$_t" -le "$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" ] 2>/dev/null ; then + if [ "$_new" -le "$_t" ] && \ + [ "$_t" -le "$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" ] \ + 2>/dev/null ; then _new=$((_t + 1)) fi done <"$rt_tables" @@ -317,8 +318,8 @@ add_missing_routes () [ -n "$_iface" ] || continue _table_id="${table_id_prefix}${_ip}" - if [ -z "$(ip route show table "$_table_id" 2>/dev/null)" -o \ - "$1" = "force" ] ; then + if [ -z "$(ip route show table "$_table_id" 2>/dev/null)" ] || \ + [ "$1" = "force" ] ; then add_routing_for_ip "$_iface" "$_ip" fi done diff --git a/ctdb/config/events/legacy/60.nfs.script b/ctdb/config/events/legacy/60.nfs.script index 2eb90b421c8..1b87b3d27e3 100755 --- a/ctdb/config/events/legacy/60.nfs.script +++ b/ctdb/config/events/legacy/60.nfs.script @@ -139,7 +139,7 @@ nfs_check_service () fi if $_ok ; then - if [ $unhealthy_after -ne 1 -o $restart_every -ne 0 ] ; then + if [ $unhealthy_after -ne 1 ] || [ $restart_every -ne 0 ] ; then ctdb_counter_init "$_progname" fi exit 0 @@ -179,7 +179,7 @@ nfs_check_service () # shellcheck disable=SC2031 nfs_restart_service () { - if [ -z "$service_stop_cmd" -o -z "$service_start_cmd" ] ; then + if [ -z "$service_stop_cmd" ] || [ -z "$service_start_cmd" ] ; then die "ERROR: Can not restart service \"${_progname}\" without corresponding service_start_cmd/service_stop_cmd settings" fi diff --git a/ctdb/tests/shellcheck/scripts/local.sh b/ctdb/tests/shellcheck/scripts/local.sh index ab92aaa5575..84019144009 100644 --- a/ctdb/tests/shellcheck/scripts/local.sh +++ b/ctdb/tests/shellcheck/scripts/local.sh @@ -28,14 +28,7 @@ shellcheck_test () # SC2164: Use cd ... || exit in case cd fails. # - Most hits are on known directories. Too # much churn, maybe later. - # SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not - # well defined. - # SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not - # well defined. - # - This can cause issues but the number of - # true positives will be very low. Too much - # churn, maybe later. - _excludes="SC1090,SC1091,SC2162,SC2164,SC2166" + _excludes="SC1090,SC1091,SC2162,SC2164" unit_test shellcheck --exclude="$_excludes" "$@" else echo "WARNING: shellcheck not installed, skipping test" diff --git a/ctdb/tools/ctdb_diagnostics b/ctdb/tools/ctdb_diagnostics index ccaf85963cb..f86d14d389e 100755 --- a/ctdb/tools/ctdb_diagnostics +++ b/ctdb/tools/ctdb_diagnostics @@ -217,7 +217,7 @@ t=$(date +%s) for i in $nodes; do t2=$(onnode "$i" date +%s) d=$((t2 - t)) - if [ "$d" -gt 30 -o "$d" -lt -30 ]; then + if [ "$d" -gt 30 ] || [ "$d" -lt -30 ]; then error "time on node $i differs by $d seconds" fi done diff --git a/ctdb/tools/onnode b/ctdb/tools/onnode index d6595fff4aa..35c46c3c779 100755 --- a/ctdb/tools/onnode +++ b/ctdb/tools/onnode @@ -106,7 +106,7 @@ echo_nth () node="$1" fi - if [ -n "$node" -a "$node" != "#DEAD" ] ; then + if [ -n "$node" ] && [ "$node" != "#DEAD" ] ; then echo "$node" else echo "${prog}: \"node ${n}\" does not exist" >&2 @@ -213,7 +213,7 @@ get_nodes () local f="${CTDB_BASE}/nodes" if [ -n "$ctdb_nodes_file" ] ; then f="$ctdb_nodes_file" - if [ ! -e "$f" -a "${f#/}" = "$f" ] ; then + if [ ! -e "$f" ] && [ "${f#/}" = "$f" ] ; then # $f is relative, try in $CTDB_BASE f="${CTDB_BASE}/${f}" fi