Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit eddf0dc

Browse files
William Douglasbryteise
authored andcommitted
Fix shellcheck SC2048 error
Correctly quote arrays. Also improve some commands getting the array content (fixes space issues with quoting). Signed-off-by: William Douglas <[email protected]>
1 parent 6a6a907 commit eddf0dc

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

test/functional/testlib.bash

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,8 @@ copy_manifest() {
609609
sudo tar --preserve-permissions -xf "$to_path"/pack-"$bundle"-from-0.tar --strip-components 1 --directory "$to_path"/files
610610

611611
# copy the tar file of each fullfile from a previous version
612-
files=("$(ls -I "*.tar" "$to_path"/files)")
613-
for bundle_file in ${files[*]}; do
612+
mapfile -t files < <(ls -I "*.tar" "$to_path"/files)
613+
for bundle_file in "${files[@]}"; do
614614
if [ ! -e "$to_path"/files/"$bundle_file".tar ]; then
615615
# find the existing tar in previous versions and copy
616616
# it to the current directory
@@ -1139,8 +1139,7 @@ set_as_minversion() { # swupd_function
11391139
mom="$minversion_path"/Manifest.MoM
11401140

11411141
mapfile -t bundles < <(awk '/^M\.\.\./ { print $4 }' "$mom")
1142-
IFS=$'\n'
1143-
for bundle in ${bundles[*]}; do
1142+
for bundle in "${bundles[@]}"; do
11441143

11451144
# search for the latest manifest version for the bundle
11461145
manifest="$minversion_path"/Manifest."$bundle"
@@ -1159,8 +1158,8 @@ set_as_minversion() { # swupd_function
11591158
# extract the content of the zero pack in the files directory so we have
11601159
# all files available to create future delta packs
11611160
sudo tar --preserve-permissions -xf "$webdir_path"/"$minversion"/pack-"$bundle"-from-0.tar --strip-components 1 --directory "$webdir_path"/"$minversion"/files
1162-
files=("$(ls -I "*.tar" "$webdir_path"/"$minversion"/files)")
1163-
for bundle_file in ${files[*]}; do
1161+
mapfile -t files < <(ls -I "*.tar" "$webdir_path"/"$minversion"/files)
1162+
for bundle_file in "${files[@]}"; do
11641163
if [ ! -e "$webdir_path"/"$minversion"/files/"$bundle_file".tar ]; then
11651164
create_tar "$webdir_path"/"$minversion"/files/"$bundle_file"
11661165
fi
@@ -1175,7 +1174,6 @@ set_as_minversion() { # swupd_function
11751174
create_tar "$manifest"
11761175

11771176
done
1178-
unset IFS
11791177

11801178
# update the MoM
11811179
update_manifest "$mom" minversion "$minversion"
@@ -1642,10 +1640,9 @@ update_hashes_in_mom() { # swupd_function
16421640
validate_item "$manifest"
16431641
path=$(dirname "$manifest")
16441642

1645-
IFS=$'\n'
16461643
if [ "$(basename "$manifest")" = Manifest.MoM ]; then
1647-
bundles=("$(sudo cat "$manifest" | grep -x "M.\\.\\..*" | awk '{ print $4 }')")
1648-
for bundle in ${bundles[*]}; do
1644+
mapfile -t bundles < <(awk '/^M.\.\./ { print $4 }' "$manifest")
1645+
for bundle in "${bundles[@]}"; do
16491646
# if the hash of the manifest changed, update it
16501647
bundle_old_hash=$(get_hash_from_manifest "$manifest" "$bundle")
16511648
bundle_new_hash=$(sudo "$SWUPD" hashdump --quiet "$path"/Manifest."$bundle")
@@ -1664,7 +1661,6 @@ update_hashes_in_mom() { # swupd_function
16641661
echo "The provided manifest is not the MoM"
16651662
return 1
16661663
fi
1667-
unset IFS
16681664

16691665
}
16701666

@@ -1735,14 +1731,12 @@ bump_format() { # swupd_function
17351731
update_manifest -p "$middle_version_path"/Manifest.os-core file-version /usr/share/defaults/swupd/format "$middle_version"
17361732

17371733
mapfile -t bundles < <(awk '/^M\.\.\./ { print $4 }' "$mom")
1738-
IFS=$'\n'
1739-
for bundle in ${bundles[*]}; do
1734+
for bundle in "${bundles[@]}"; do
17401735
manifest="$middle_version_path"/Manifest."$bundle"
17411736
update_manifest -p "$manifest" format "$format"
17421737
update_manifest -p "$manifest" version "$middle_version"
17431738
update_manifest "$manifest" previous "$version"
17441739
done
1745-
unset IFS
17461740
update_hashes_in_mom "$mom"
17471741

17481742
# update the minversion
@@ -4607,7 +4601,7 @@ print_stack() {
46074601

46084602
echo "An error occurred"
46094603
echo "Function stack (most recent on top):"
4610-
for func in ${FUNCNAME[*]}; do
4604+
for func in "${FUNCNAME[@]}"; do
46114605
if [ "$func" != "print_stack" ] && [ "$func" != "terminate" ]; then
46124606
echo -e "\\t$func"
46134607
fi

0 commit comments

Comments
 (0)