1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

ctdb-scripts: Avoid ShellCheck warning SC2295

For example:

In /home/martins/samba/samba/ctdb/tools/onnode line 304:
    [ "$nodes" != "${nodes%[ ${nl}]*}" ] && verbose=true
                             ^---^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns.

Did you mean:
    [ "$nodes" != "${nodes%[ "${nl}"]*}" ] && verbose=true

For more information:
  https://www.shellcheck.net/wiki/SC2295 -- Expansions inside ${..} need to b...

Who knew?  Thanks ShellCheck!

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2022-05-27 23:23:48 +10:00 committed by Amitay Isaacs
parent 00f1d6d947
commit db37043bc5
4 changed files with 9 additions and 7 deletions

View File

@ -346,7 +346,7 @@ remove_bogus_routes ()
# be done with grep, but let's do it with shell prefix removal
# to avoid unnecessary processes. This falls through if
# "@${_i}@" isn't present in $_ips.
[ "$_ips" = "${_ips#*@${_i}@}" ] || continue
[ "$_ips" = "${_ips#*@"${_i}"@}" ] || continue
echo "Removing ip rule/routes for unhosted public address $_i"
del_routing_for_ip "$_i"

View File

@ -235,7 +235,7 @@ run_one_test ()
local test_dir test_suite_dir reldir
test_dir=$(cd "$CTDB_TEST_DIR" && pwd)
test_suite_dir=$(cd "$CTDB_TEST_SUITE_DIR" && pwd)
reldir="${test_suite_dir#${test_dir}/}"
reldir="${test_suite_dir#"${test_dir}"/}"
export CTDB_TEST_TMP_DIR="${test_state_dir}/${reldir}"
rm -rf "$CTDB_TEST_TMP_DIR"
@ -260,7 +260,7 @@ run_tests ()
# Can't find it? Check relative to CTDB_TEST_DIR.
# Strip off current directory from beginning,
# if there, just to make paths more friendly.
f="${CTDB_TEST_DIR#${PWD}/}/${f}"
f="${CTDB_TEST_DIR#"${PWD}"/}/${f}"
fi
if [ -d "$f" ] ; then
@ -268,7 +268,7 @@ run_tests ()
test_dir=$(cd "$CTDB_TEST_DIR" && pwd)
dir=$(cd "$f" && pwd)
reldir="${dir#${test_dir}/}"
reldir="${dir#"${test_dir}"/}"
case "$reldir" in
*/*/*)

View File

@ -469,8 +469,10 @@ node_has_status ()
while read -r line ; do
# This needs to be done in 2 steps to
# avoid false matches.
local line_bits="${line#|${pnn}|*|}"
local line_bits="${line#|"${pnn}"|*|}"
[ "$line_bits" = "$line" ] && continue
# shellcheck disable=SC2295
# This depends on $bits being a pattern
[ "${line_bits#${bits}}" != "$line_bits" ] && \
return 0
done

View File

@ -148,7 +148,7 @@ get_nodes_with_status ()
fi
local nl="
"
ctdb_status_output="${ctdb_status_output#*${nl}}"
ctdb_status_output="${ctdb_status_output#*"${nl}"}"
fi
(
@ -301,7 +301,7 @@ else
# If $nodes contains a space or a newline then assume multiple nodes.
nl="
"
[ "$nodes" != "${nodes%[ ${nl}]*}" ] && verbose=true
[ "$nodes" != "${nodes%[ "${nl}"]*}" ] && verbose=true
fi
pids=""