Skip to contentSkip to conversation

xfs/227: fix bad variable expansion

PATCH In review Zorro Lang 2 participants 2 messages Apr 17 – Apr 22

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH 1/1 xfs/227: fix bad variable expansion

The create_data() set cmd_str to "-c \"resvsp $((off * 4096)) 4096\". That cause xfs_io can't split the command line properly, it fails as:

command ""resvsp" not found

Fixes aaf40fb7 ("fstests: xfs/227 is really slow")
---
 tests/xfs/227 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tests/xfs/227 +3 -3
index 7f8ee2db..ed505b18 100755
@@ -78,13 +78,13 @@ create_attrs()
 create_data()
 {
 	local blocks=$1
-	local cmd_str
+	local cmd_args=()
 
 	for off in `seq $blocks -1 0`; do
-		cmd_str="-c \"resvsp $((off * 4096)) 4096\" $cmd_str"
+		cmd_args+=("-c" "resvsp $((off * 4096)) 4096")
 	done
 	$XFS_IO_PROG -f -c "truncate $((($blocks + 1) * 4096))" \
-			$cmd_str $2 >> seqres.full 2>&1
+			"${cmd_args[@]}" $2 >> $seqres.full 2>&1
 }
 
 # create the designated file with a certain number of attributes and a certain
Signature · 1 line
2.52.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Zorro Lang

The create_data() set cmd_str to "-c \"resvsp $((off * 4096)) 4096\". That cause xfs_io can't split the command line properly, it fails as:

command ""resvsp" not found

Fixes aaf40fb7 ("fstests: xfs/227 is really slow")

Glomming CLI arguments into a string is quite a bash antipattern.

--D

Quoted 29 lines
---
 tests/xfs/227 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tests/xfs/227 +3 -3
index 7f8ee2db..ed505b18 100755
@@ -78,13 +78,13 @@ create_attrs()
 create_data()
 {
 	local blocks=$1
-	local cmd_str
+	local cmd_args=()
 
 	for off in `seq $blocks -1 0`; do
-		cmd_str="-c \"resvsp $((off * 4096)) 4096\" $cmd_str"
+		cmd_args+=("-c" "resvsp $((off * 4096)) 4096")
 	done
 	$XFS_IO_PROG -f -c "truncate $((($blocks + 1) * 4096))" \
-			$cmd_str $2 >> seqres.full 2>&1
+			"${cmd_args[@]}" $2 >> $seqres.full 2>&1
 }
 
 # create the designated file with a certain number of attributes and a certain
Signature · 1 line
2.52.0