Skip to contentSkip to conversation

tests: shell: quote reference to array to iterate over empty string

PATCH New Pablo Neira Ayuso 1 participant 1 message Nov 21, 2023 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 tests: shell: quote reference to array to iterate over empty string

This patch restores coverage for non-interval set backend.

Use "${FLAGS[@]}" in loop, otherwise empty string is skipped in the iteration. This snippet:

FLAGS=("")
available_flags FLAGS "single"

  for flags in "${FLAGS[@]}" ; do
          echo $flags
  done

... now shows the empty string:

  # bash test.sh

interval

Fixes ed927baa4fd8 ("tests: shell: skip pipapo set backend in transactions/30s-stress")
---
 tests/shell/testcases/transactions/30s-stress | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/shell/testcases/transactions/30s-stress +1 -1
index ef3e1d3e3e4b..e92b922660b8 100755
@@ -324,7 +324,7 @@ random_elem()
 
 			FLAGS=("")
 			available_flags FLAGS $key
-			for flags in ${FLAGS[@]} ; do
+			for flags in "${FLAGS[@]}" ; do
 				cnt=$((cnt+1))
 				if [ $f -ne fkr ] ;then
 					f=$((f+1))
Signature · 1 line
2.30.2