From 5b7c6f52e6177100210dff5d066129e28d284331 Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Sun, 22 Jul 2018 10:54:11 -0600 Subject: [PATCH] abuild: Fix shellcheck errors Fix 6 new errors found by shellcheck 0.4.6 SC2155: Declare and assign separately to avoid masking return values. 4 x SC2086: Double quote to prevent globbing and word splitting. SC2196: egrep is non-standard and deprecated. Use grep -E instead. One of the SC2086 errors is masked because it needs word splitting. Change-Id: I7f869e6d208f7247f739619c538be6075b802719 Signed-off-by: Martin Roth Reviewed-on: https://review.coreboot.org/27597 Tested-by: build bot (Jenkins) Reviewed-by: Alex Thiessen --- util/abuild/abuild | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/util/abuild/abuild b/util/abuild/abuild index f67117c50c..3831d59781 100755 --- a/util/abuild/abuild +++ b/util/abuild/abuild @@ -166,13 +166,16 @@ function mainboard_vendor # If a directory contains multiple boards, returns them all. function normalize_target { + # TODO: Change 'targets' variable to an array local targets + local VARIANT_UC - local VARIANT_UC=$(echo "${variant}" | tr '[:lower:]' '[:upper:]') + VARIANT_UC=$(echo "${variant}" | tr '[:lower:]' '[:upper:]') targets=$(get_mainboards "$1") if [ -n "$targets" ]; then - targets=$(grep "${VARIANT_UC}\$" <<< ${targets}) + # shellcheck disable=SC2086 + targets="$(grep "${VARIANT_UC}\$" <<< ${targets})" echo "$targets" return fi @@ -355,10 +358,10 @@ function compile_target CURR=$( pwd ) #stime=`perl -e 'print time();' 2>/dev/null || date +%s` - eval $BUILDPREFIX $MAKE "$verboseopt" DOTCONFIG="${build_dir}/config.build" obj="${build_dir}" objutil="$TARGET/sharedutils" BUILD_TIMELESS=$TIMELESS \ + eval "$BUILDPREFIX" "$MAKE" "$verboseopt" DOTCONFIG="${build_dir}/config.build" obj="${build_dir}" objutil="$TARGET/sharedutils" BUILD_TIMELESS=$TIMELESS \ &> "${build_dir}/make.log" ; \ MAKE_FAILED=$? - cp ${ROOT}/.xcompile "${build_dir}/xcompile.build" + cp "${ROOT}/.xcompile" "${build_dir}/xcompile.build" cd "${build_dir}" || return $? etime=$(perl -e 'print time();' 2>/dev/null || date +%s) @@ -459,7 +462,7 @@ function build_config return fi - required_arches=$(egrep "^CONFIG_ARCH_(BOOTBLOCK|R.MSTAGE|VERSTAGE)" "$TARGET/${BUILD_NAME}/config.build" | \ + required_arches=$(grep -E "^CONFIG_ARCH_(BOOTBLOCK|R.MSTAGE|VERSTAGE)" "$TARGET/${BUILD_NAME}/config.build" | \ sed "s,^CONFIG_ARCH_[^_]*_\([^=]*\)=.*$,\1," |sort -u |tr 'A-Z\n\r' 'a-z ') # shellcheck disable=SC2016,SC2059 missing_arches=$(printf 'include .xcompile\nall: ; @echo $(foreach arch,'"$required_arches"',$(if $(filter $(arch),$(SUBARCH_SUPPORTED)),,$(arch)))' | $MAKE --no-print-directory -f -) @@ -800,7 +803,7 @@ build_targets() local XMLFILE="$ABSPATH/__util.xml" rm -f "${XMLFILE}" stime=$(perl -e 'print time();' 2>/dev/null || date +%s) - $BUILDPREFIX $MAKE -j "$cpus" DOTCONFIG="$TMPCFG" obj="$TARGET/temp" objutil="$TARGET/sharedutils" tools > "$TARGET/sharedutils/make.log" 2>&1 + $BUILDPREFIX "$MAKE" -j "$cpus" DOTCONFIG="$TMPCFG" obj="$TARGET/temp" objutil="$TARGET/sharedutils" tools > "$TARGET/sharedutils/make.log" 2>&1 local ret=$? etime=$(perl -e 'print time();' 2>/dev/null || date +%s) local duration=$(( etime - stime )) @@ -831,8 +834,6 @@ build_targets() } fi -debug "ROOT=$ROOT" - junit '' junit ''