ctdb-tests: Avoid ShellCheck warnings
commitb2026e92d68c12e0b6169742954a706b6faa7bf8
authorMartin Schwenke <mschwenke@ddn.com>
Sun, 2 Jul 2023 23:32:26 +0000 (3 09:32 +1000)
committerMartin Schwenke <martins@samba.org>
Wed, 5 Jul 2023 11:18:37 +0000 (5 11:18 +0000)
treee90adc4f7ebbba5e7ca7d0fa496a2d19c53b7e54
parenta45a76fd19ce486049583e1e7435320be40f9ef9
ctdb-tests: Avoid ShellCheck warnings

These are all trivial, so handle them in bulk.

* Change code to avoid (approximately sorted by frequency):

  SC2004 $/${} is unnecessary on arithmetic variables.
  SC2086 Double quote to prevent globbing and word splitting.
  SC2162 read without -r will mangle backslashes.
  SC2254 Quote expansions in case patterns to match literally rather than as a glob.
  SC2154 (warning): <variable> is referenced but not assigned.
  SC3037 (warning): In POSIX sh, echo flags are undefined.
  SC2016 (info): Expressions don't expand in single quotes, use double quotes for that.
  SC2069 (warning): To redirect stdout+stderr, 2>&1 must be last (or use '{ cmd > file; } 2>&1' to clarify).
  SC2124 (warning): Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
  SC2166 (warning): Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
  SC2223 (info): This default assignment may cause DoS due to globbing. Quote it.

* Locally disable checks:

  SC2034 (warning): <variable> appears unused. Verify use (or export if used externally).
  SC2086 (info): Double quote to prevent globbing and word splitting. [once]
  SC2120 (warning): <function> references arguments, but none are ever passed.
  SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).

While touching reads for SC2162, switch unused variables to "_"
instead of "_x", which seems to be preferred by ShellCheck.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
12 files changed:
ctdb/tests/UNIT/eventscripts/scripts/05.system.sh
ctdb/tests/UNIT/eventscripts/scripts/10.interface.sh
ctdb/tests/UNIT/eventscripts/scripts/11.natgw.sh
ctdb/tests/UNIT/eventscripts/scripts/13.per_ip_routing.sh
ctdb/tests/UNIT/eventscripts/scripts/48.netbios.sh
ctdb/tests/UNIT/eventscripts/scripts/49.winbind.sh
ctdb/tests/UNIT/eventscripts/scripts/50.samba.sh
ctdb/tests/UNIT/eventscripts/scripts/60.nfs.sh
ctdb/tests/UNIT/eventscripts/scripts/91.lvs.sh
ctdb/tests/UNIT/eventscripts/scripts/debug_locks.sh
ctdb/tests/UNIT/eventscripts/scripts/local.sh
ctdb/tests/UNIT/eventscripts/scripts/statd-callout.sh