Skip to content

Commit

Permalink
Explicitly expand array values
Browse files Browse the repository at this point in the history
Fixes the following shellcheck errors:

    SC2145 (error): Argument mixes string and array. Use * or separate argument.
    SC2199 (error): Arrays implicitly concatenate in [[ ]]. Use a loop (or explicit * instead of @).

https://www.shellcheck.net/wiki/SC2145
https://www.shellcheck.net/wiki/SC2199

Also fixes a typo in SUPPORTED_INTERFACE_SWITCHER_MODES.
  • Loading branch information
mandre committed Sep 23, 2024
1 parent 3d553bf commit 63246d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions hack/run-e2e-test-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export SRIOV_NETWORK_OPERATOR_IMAGE="${SRIOV_NETWORK_OPERATOR_IMAGE:-sriov-netwo
export SRIOV_NETWORK_CONFIG_DAEMON_IMAGE="${SRIOV_NETWORK_CONFIG_DAEMON_IMAGE:-origin-sriov-network-config-daemon:e2e-test}"
export KUBECONFIG="${KUBECONFIG:-${HOME}/.kube/config}"
INTERFACES_SWITCHER="${INTERFACES_SWITCHER:-"test-suite"}"
SUPPORTED_INTERFACE_SWTICHER_MODES=("test-suite", "system-service")
SUPPORTED_INTERFACE_SWITCHER_MODES=("test-suite", "system-service")
RETRY_MAX=10
INTERVAL=10
TIMEOUT=300
Expand All @@ -16,9 +16,9 @@ while test $# -gt 0; do
case "$1" in
--device-netns-switcher)
INTERFACES_SWITCHER="$2"
if [[ ! "${SUPPORTED_INTERFACE_SWTICHER_MODES[@]}" =~ "${INTERFACES_SWITCHER}" ]]; then
if [[ ! "${SUPPORTED_INTERFACE_SWITCHER_MODES[*]}" =~ "${INTERFACES_SWITCHER}" ]]; then
echo "Error: unsupported interface switching mode: ${INTERFACES_SWITCHER}!"
echo "Supported modes are: ${SUPPORTED_INTERFACE_SWTICHER_MODES[@]}"
echo "Supported modes are: ${SUPPORTED_INTERFACE_SWITCHER_MODES[*]}"
exit 1
fi
shift
Expand Down
4 changes: 2 additions & 2 deletions hack/vf-netns-switcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ variables_check(){
check_empty_var(){
local var_name="$1"

if [[ -z "${!var_name[@]}" ]];then
if [[ -z "${!var_name[*]}" ]];then
echo "Error: $var_name is empty..."
return 1
fi
Expand Down Expand Up @@ -403,7 +403,7 @@ for netns in "${netnses[@]}";do
done

if [[ "${#pcis[@]}" == "0" ]];then
echo "Error: could not get pci addresses of interfaces ${pfs[@]}!!"
echo "Error: could not get pci addresses of interfaces ${pfs[*]}!!"
exit 1
fi

Expand Down

0 comments on commit 63246d6

Please sign in to comment.