From 95d0bdaf72da2ebe830911d4717e2055709eaac9 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Mon, 25 Jan 2016 18:25:53 -0800 Subject: [PATCH] *: Fix PIPESTATUS checks for bash 4.3 The one-liner `[[ -z ${PIPESTATUS[*]#0} ]]` no longer works because the expansion still includes spaces even if all the values are zero. Somehow that didn't matter in bash 4.2 but it does mater in 4.3 to be consistent with the general behavior of variables in [[ tests. --- build_library/toolchain_util.sh | 6 +++++- common.sh | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/build_library/toolchain_util.sh b/build_library/toolchain_util.sh index cae650823e..5dbacdc135 100644 --- a/build_library/toolchain_util.sh +++ b/build_library/toolchain_util.sh @@ -383,9 +383,13 @@ install_cross_libs() { gcc_get_latest_profile() { local prefix="${1}-" local suffix="${2+-$2}" + local status gcc-config -l | cut -d' ' -f3 | grep "^${prefix}[0-9\\.]*${suffix}$" | tail -n1 + # return 1 if anything in the above pipe failed - [[ -z ${PIPESTATUS[*]#0} ]] || return 1 + for status in ${PIPESTATUS[@]}; do + [[ $status -eq 0 ]] || return 1 + done } # Update to the latest GCC profile for a given CHOST if required diff --git a/common.sh b/common.sh index 2c037a7c18..e589d0b1f6 100644 --- a/common.sh +++ b/common.sh @@ -718,7 +718,7 @@ make_digests() { # Usage: verify_digests [-d file.DIGESTS] file1 [file2...] # If -d is not specified file1.DIGESTS will be used verify_digests() { - local digests + local digests filename hash_type status if [[ "$1" == "-d" ]]; then [[ -n "$2" ]] || die "-d requires an argument" digests="$(readlink -f "$2")" @@ -735,7 +735,9 @@ verify_digests() { grep -A1 -i "^# ${hash_type} HASH$" "${digests}" | \ grep "$filename$" | ${hash_type}sum -c - --strict || return 1 # Also check that none of the greps failed in the above pipeline - [[ -z ${PIPESTATUS[*]#0} ]] || return 1 + for status in ${PIPESTATUS[@]}; do + [[ $status -eq 0 ]] || return 1 + done done done popd >/dev/null