shared/298: fix random deletion when filenames contain spaces
authorDarrick J. Wong <djwong@kernel.org>
Wed, 7 Jul 2021 00:21:23 +0000 (17:21 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sun, 18 Jul 2021 14:27:11 +0000 (22:27 +0800)
Correct the deletion loop in this test to work properly when there are
files in $here that have spaces in their name.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/shared/298

index 981a4df..bd52b6a 100755 (executable)
@@ -163,7 +163,7 @@ get_holes $img_file > $fiemap_ref
 
 # Delete some files
 find $loop_mnt -type f -print | $AWK_PROG \
-       'BEGIN {srand()}; {if(rand() > 0.7) print $1;}' | xargs rm
+       'BEGIN {srand()}; {if(rand() > 0.7) printf("%s\0", $0);}' | xargs -0 rm
 echo "done."
 
 echo -n "Running fstrim..."