]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: use find instead of ls for more robust processing
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Fri, 10 Apr 2026 18:23:27 +0000 (14:23 -0400)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Mon, 4 May 2026 11:31:09 +0000 (07:31 -0400)
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
tests/ts/blkid/low-probe
tests/ts/blkid/lowprobe-pt
tests/ts/lsblk/lsblk
tests/ts/lscpu/lscpu
tests/ts/lsmem/lsmem
tests/ts/wipefs/wipefs

index c3f396439c51e7ca46b3fb0987cbf20ce17160fb..56a7949e3506125b0e148177f151d14c47e5efc3 100755 (executable)
@@ -28,7 +28,7 @@ ts_check_prog "xz"
 
 mkdir -p $TS_OUTDIR/images-fs
 
-for img in $(ls $TS_SELF/images-fs/*.img.xz | sort); do
+for img in $(find "$TS_SELF"/images-fs/ -maxdepth 1 -name "*.img.xz" | sort); do
        name=$(basename $img .img.xz)
        outimg=$TS_OUTDIR/images-fs/${name}.img
 
index 955de076d585305ce1f152882381a2e5d4d5d445..429557b9a3fd573739137d0fad5c3a97dbc49dd5 100755 (executable)
@@ -28,7 +28,7 @@ ts_check_prog "xz"
 
 mkdir -p $TS_OUTDIR/images-pt
 
-for img in $(ls $TS_SELF/images-pt/*.img.xz | sort); do
+for img in $(find "$TS_SELF"/images-pt/ -maxdepth 1 -name "*.img.xz" 2>/dev/null | sort); do
        name=$(basename $img .img.xz)
        outimg=$TS_OUTDIR/images-pt/${name}.img
 
index 509b8d0cd903bbb909ec83617545dfabb4f129b4..2c83ffc7b5c7beeb2f3fdc520e37e5e87aef7e96 100755 (executable)
@@ -26,7 +26,7 @@ ts_check_test_command "$TS_CMD_LSBLK"
 ts_check_prog xz
 ts_check_prog tar
 
-for dump in $(ls $TS_SELF/dumps/*.tar.xz | sort); do
+for dump in $(find "$TS_SELF"/dumps/ -maxdepth 1 -name "*.tar.xz" | sort); do
        name=$(basename $dump .tar.xz)
        dumpdir="$TS_OUTDIR/dumps"
 
@@ -38,12 +38,12 @@ for dump in $(ls $TS_SELF/dumps/*.tar.xz | sort); do
        # from the tarball due to changes in lsblk formatting etc. We keep up to
        # date version in tests/expected/lsblk.
        #
-       for cols_file in $(ls $dumpdir/$name/*.cols | sort); do
+       for cols_file in $(find "$dumpdir"/"$name"/ -iname "*.cols" | sort); do
                subname=$(basename $cols_file .cols)
                subtestname="${name}-${subname}"
 
                ts_init_subtest $subtestname
-               cols=$(cat $cols_file)
+               cols=$(<"$cols_file")
                ${TS_CMD_LSBLK} --sysroot "${dumpdir}/${name}" \
                                --output $cols \
                                >> ${TS_OUTPUT} 2>> "$TS_ERRLOG"
index 3b7eb3592d732c3bbdeb89cfda3f269d78e14f15..7c073835b305b34ec0d28dd29063b2b961e9f559 100755 (executable)
@@ -26,7 +26,7 @@ ts_check_prog "tar"
 ts_check_prog "gzip"
 ts_check_test_command "$TS_CMD_LSCPU"
 
-for dump in $(ls $TS_SELF/dumps/*.tar.gz | sort); do
+for dump in $(find "$TS_SELF"/dumps/ -maxdepth 1 -name "*.tar.gz" | sort); do
        name=$(basename $dump .tar.gz)
        dumpdir="$TS_OUTDIR/dumps"
 
index 5a40e549ecefdb75b02a50c2a4d95120056e6631..c3011dcb378b62be0c61bf1b564e24d63db92f2f 100755 (executable)
@@ -36,7 +36,7 @@ function do_lsmem {
 
 }
 
-for dump in $(ls $TS_SELF/dumps/*.tar.bz2 | sort); do
+for dump in $(find "$TS_SELF"/dumps/ -maxdepth 1 -name "*.tar.bz2" | sort); do
         name=$(basename $dump .tar.bz2)
         dumpdir="$TS_OUTDIR/dumps"
 
index bc2d7812d2b6aac5baa6d1fe5e044102354cf894..fef60d6f0091974f53fbc45ea152a3c38c25967f 100755 (executable)
@@ -22,7 +22,7 @@ mkdir -p "$backups"
 $TS_CMD_WIPEFS --all --backup="${backups}" ${img} &>/dev/null || ts_die "wipefs failed"
 
 #there should be just one magic string/backup file in this case
-INFILE=$(ls $backups/wipefs-$(basename ${img})-*.bak)
+INFILE=$(find "$backups/" -iname "wipefs-$(basename "${img}")-*.bak")
 OFFT=$(echo $INFILE | sed 's/^.*-\(.*\).bak$/\1/')
 dd if=$INFILE of=$img bs=1 conv=notrunc seek=$(($OFFT)) &>/dev/null