Alex Thiessen has uploaded this change for review.

View Change

util/scripts/ucode_h_to_bin.sh: Fix `shellcheck` warning

The attempted fix in commit 21530bd4 "util/scripts/ucode_h_to_bin.sh:
Drop disruptive quotes" triggers a `shellcheck` warning because a string
is being split implicitly:

In util/scripts/ucode_h_to_bin.sh line 52:
for UCODE in ${@:2}; do
^-- SC2068: Double quote array expansions to avoid re-splitting elements.

Reference: https://github.com/koalaman/shellcheck/wiki/SC2068

Also, accidental globbing will occur, e.g. when a file name contains an
asterisk or a question mark.

The underlying reason for this weirdness is this script's interface
which is neither _usual_ nor well-documented (the code accepts things
which don't adhere to the interface, e.g. multiple file lists or whole
directory names).

Make the split explicit by introducing a separate array variable
containing the strings, split on spaces. This also will not trigger
globbing.

Change-Id: I5fb7d0370ca46e8eb850449612d201d5d164fb6a
Signed-off-by: Alex Thiessen <alex.thiessen.de+coreboot@gmail.com>
---
M util/scripts/ucode_h_to_bin.sh
1 file changed, 3 insertions(+), 1 deletion(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/45/40945/1
diff --git a/util/scripts/ucode_h_to_bin.sh b/util/scripts/ucode_h_to_bin.sh
index cb403a4..1072bb9 100755
--- a/util/scripts/ucode_h_to_bin.sh
+++ b/util/scripts/ucode_h_to_bin.sh
@@ -49,7 +49,9 @@
fi
}

-for UCODE in ${@:2}; do
+IFS=' ' read -r -a UCODE_PARAM <<< "${@:2}"
+
+for UCODE in "${UCODE_PARAM[@]}"; do
if [ -d "$UCODE" ]; then
for f in "$UCODE/"*.inc
do

To view, visit change 40945. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I5fb7d0370ca46e8eb850449612d201d5d164fb6a
Gerrit-Change-Number: 40945
Gerrit-PatchSet: 1
Gerrit-Owner: Alex Thiessen <alex.thiessen.de+coreboot@gmail.com>
Gerrit-MessageType: newchange