summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Roth <martinroth@google.com>2015-12-17 12:49:15 -0700
committerMartin Roth <martinroth@google.com>2015-12-20 01:18:08 +0100
commit9f25da1f490e3e6ce02936c8d6404c68699b5aff (patch)
treedce546b149ee8efb6a20f7d00fe5d871150fd295
parent072b5aa5c5a8ea23012c7a948d788b6955ba0ee0 (diff)
downloadcoreboot-staging-9f25da1f490e3e6ce02936c8d6404c68699b5aff.zip
coreboot-staging-9f25da1f490e3e6ce02936c8d6404c68699b5aff.tar.gz
board_status.sh: Double quote variables to prevent globbing and word splitting.
Quoting variables prevents word splitting and glob expansion, and prevents the script from breaking when input contains spaces, line feeds, glob characters and such. See shellcheck warning SC2086. Change-Id: I7256d2fc2a22bce7723950a534fef6d57cbd097f Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/12761 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
-rwxr-xr-xutil/board_status/board_status.sh32
1 files changed, 16 insertions, 16 deletions
diff --git a/util/board_status/board_status.sh b/util/board_status/board_status.sh
index 410488f..1fb599e 100755
--- a/util/board_status/board_status.sh
+++ b/util/board_status/board_status.sh
@@ -70,7 +70,7 @@ _cmd()
fi
if [ "$1" -eq "$REMOTE" ] && [ -n "$REMOTE_HOST" ]; then
- ssh root@${REMOTE_HOST} "$2" > "$pipe_location" 2>&1
+ ssh "root@${REMOTE_HOST}" "$2" > "$pipe_location" 2>&1
else
$2 > "$pipe_location" 2>&1
fi
@@ -227,12 +227,12 @@ fi
test_cmd $LOCAL "$cbfstool_cmd"
echo "Extracting config.txt from build/coreboot.rom"
$cbfstool_cmd build/coreboot.rom extract -n config -f "${tmpdir}/config.txt" >/dev/null 2>&1
-mv ${tmpdir}/config.txt ${tmpdir}/config.short.txt
-cp ${tmpdir}/config.short.txt ${tmpcfg}
-yes "" | make DOTCONFIG=${tmpcfg} oldconfig 2>/dev/null >/dev/null
-mv ${tmpcfg} ${tmpdir}/config.txt
-rm -f ${tmpcfg}.old
-$cbfstool_cmd build/coreboot.rom print > ${tmpdir}/cbfs.txt
+mv "${tmpdir}/config.txt" "${tmpdir}/config.short.txt"
+cp "${tmpdir}/config.short.txt" "${tmpcfg}"
+yes "" | make "DOTCONFIG=${tmpcfg}" oldconfig 2>/dev/null >/dev/null
+mv "${tmpcfg}" "${tmpdir}/config.txt"
+rm -f "${tmpcfg}.old"
+$cbfstool_cmd build/coreboot.rom print > "${tmpdir}/cbfs.txt"
rom_contents=$($cbfstool_cmd build/coreboot.rom print 2>&1)
if [ -n "$(echo $rom_contents | grep payload_config)" ]; then
echo "Extracting payload_config from build/coreboot.rom"
@@ -246,7 +246,7 @@ md5sum -b build/coreboot.rom > "${tmpdir}/rom_checksum.txt"
# Obtain board and revision info to form the directory structure:
# <vendor>/<board>/<revision>/<timestamp>
-mainboard_dir="$(grep CONFIG_MAINBOARD_DIR ${tmpdir}/config.txt | awk -F '"' '{ print $2 }')"
+mainboard_dir="$(grep CONFIG_MAINBOARD_DIR "${tmpdir}/config.txt" | awk -F '"' '{ print $2 }')"
vendor=$(echo "$mainboard_dir" | awk -F '/' '{ print $1 }')
mainboard=$(echo "$mainboard_dir" | awk -F '/' '{ print $2 }')
@@ -267,12 +267,12 @@ mv "${tmpdir}/config.short.txt" "${tmpdir}/${results}"
mv "${tmpdir}/cbfs.txt" "${tmpdir}/${results}"
mv "${tmpdir}/rom_checksum.txt" "${tmpdir}/${results}"
-touch ${tmpdir}/${results}/revision.txt
-printf "Local revision: %s\n" "$($getrevision -l)" >> ${tmpdir}/${results}/revision.txt
-printf "Tagged revision: %s\n" "${tagged_version}" >> ${tmpdir}/${results}/revision.txt
-printf "Upstream revision: %s\n" $($getrevision -u) >> ${tmpdir}/${results}/revision.txt
-printf "Upstream URL: %s\n" $($getrevision -U)>> ${tmpdir}/${results}/revision.txt
-printf "Timestamp: %s\n" "$timestamp" >> ${tmpdir}/${results}/revision.txt
+touch "${tmpdir}/${results}/revision.txt"
+printf "Local revision: %s\n" "$($getrevision -l)" >> "${tmpdir}/${results}/revision.txt"
+printf "Tagged revision: %s\n" "${tagged_version}" >> "${tmpdir}/${results}/revision.txt"
+printf "Upstream revision: %s\n" "$($getrevision -u)" >> "${tmpdir}/${results}/revision.txt"
+printf "Upstream URL: %s\n" "$($getrevision -U)" >> "${tmpdir}/${results}/revision.txt"
+printf "Timestamp: %s\n" "$timestamp" >> "${tmpdir}/${results}/revision.txt"
if [ -z "$SERIAL_DEVICE" ]; then
echo "Verifying that CBMEM is available on remote device"
@@ -301,7 +301,7 @@ if [ $UPLOAD_RESULTS -eq 1 ]; then
# FIXME: the board-status directory might get big over time.
# Is there a way we can push the results without fetching the
# whole repo?
- git clone $bsrepo
+ git clone "$bsrepo"
if [ $? -ne 0 ]; then
echo "Error cloning board-status repo, aborting."
exit $EXIT_FAILURE
@@ -334,7 +334,7 @@ fi
cd "$coreboot_dir"
if [ $CLOBBER_OUTPUT -eq 1 ]; then
- rm -rf ${tmpdir}
+ rm -rf "${tmpdir}"
else
echo
echo "output files are in ${tmpdir}/${results}"
OpenPOWER on IntegriCloud