diff options
author | Martin Roth <martinroth@google.com> | 2016-01-05 15:55:44 -0700 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2016-01-07 17:28:44 +0100 |
commit | 2ba837d8c7b5d929ae898006b4355649d7ea8b39 (patch) | |
tree | f9e4ae227d37e064450778ad0ddfbd4e4d414581 | |
parent | 7051dea5f4863ff1d1a08fe89dbb23bd18898974 (diff) | |
download | coreboot-2ba837d8c7b5d929ae898006b4355649d7ea8b39.tar.xz |
xcompile: Quote variables to prevent globbing and 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: Ib6ca46b64a621c4bea5c33ac312f2824b0386235
Signed-off-by: Martin Roth <martinroth@google.com>
Reviewed-on: https://review.coreboot.org/12845
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
-rwxr-xr-x | util/xcompile/xcompile | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile index 48df75b11b..b3dd074486 100755 --- a/util/xcompile/xcompile +++ b/util/xcompile/xcompile @@ -52,7 +52,7 @@ program_exists() { } -if [ "$(${XGCCPATH}/iasl 2>/dev/null | grep -c ACPI)" -gt 0 ]; then +if [ "$("${XGCCPATH}/iasl" 2>/dev/null | grep -c ACPI)" -gt 0 ]; then IASL=${XGCCPATH}iasl elif [ "$(iasl 2>/dev/null | grep -c ACPI)" -gt 0 ]; then IASL=iasl @@ -107,11 +107,11 @@ testas() { rm -f "$obj_file" [ -n "$use_dash_twidth" ] && use_dash_twidth="--$twidth" [ -n "$endian" ] && endian="-$endian" - ${gccprefix}as $use_dash_twidth $endian -o "$obj_file" $TMPFILE \ + "${gccprefix}as" $use_dash_twidth $endian -o "$obj_file" "$TMPFILE" \ 2>/dev/null || return 1 # Check output content type. - local obj_type="$(LANG=C LC_ALL= ${gccprefix}objdump -p $obj_file 2>/dev/null)" + local obj_type="$(LANG=C LC_ALL='' "${gccprefix}"objdump -p "$obj_file" 2>/dev/null)" local obj_arch="$(expr "$obj_type" : '.*format \(.[a-z0-9-]*\)')" [ "$obj_arch" = "$full_arch" ] || return 1 @@ -329,8 +329,8 @@ test_architecture() { unset TABI TARCH TBFDARCH TCLIST TENDIAN TSUPP TWIDTH unset CC_RT_EXTRA_GCC CC_RT_EXTRA_CLANG unset GCC CLANG - if type arch_config_$architecture > /dev/null; then - arch_config_$architecture + if type "arch_config_$architecture" > /dev/null; then + "arch_config_$architecture" else die "no architecture definition for $architecture" fi @@ -339,7 +339,7 @@ test_architecture() { # environment variable. # Ex: CROSS_COMPILE_arm="armv7a-cros-linux-gnueabi-" # CROSS_COMPILE_x86="i686-pc-linux-gnu-" - search="$(eval echo \$CROSS_COMPILE_$architecture 2>/dev/null)" + search="$(eval echo "\$CROSS_COMPILE_$architecture" 2>/dev/null)" search="$search $CROSS_COMPILE" for toolchain in $TCLIST; do search="$search $XGCCPATH$toolchain-$TABI-" @@ -382,7 +382,7 @@ test_architecture() { # This loops over all supported architectures. for architecture in $SUPPORTED_ARCHITECTURES; do - test_architecture $architecture + test_architecture "$architecture" detect_special_flags "$architecture" detect_compiler_runtime "$architecture" report_arch_toolchain |