diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc index a4638490ae..a30ef24e4b 100755 --- a/util/crossgcc/buildgcc +++ b/util/crossgcc/buildgcc @@ -121,9 +121,9 @@ searchtool() search="$2" fi for i in "$1" "g$1" "gnu$1"; do - if test -x "$(which $i 2>/dev/null)"; then - if test $(cat /dev/null | $i --version 2>&1 |grep -c "$search") \ - -gt 0; then + if [ -x "$(which $i 2>/dev/null)" ]; then + if [ "$(cat /dev/null | $i --version 2>&1 | grep -c "$search")" \ + -gt 0 ]; then echo $i return fi @@ -133,7 +133,7 @@ searchtool() # patch and tar also work. if [ $UNAME = "Darwin" -o $UNAME = "FreeBSD" -o $UNAME = "NetBSD" -o $UNAME = "OpenBSD" ]; then if [ "$1" = "patch" -o "$1" = "tar" ]; then - if test -x "$(which $1 2>/dev/null)"; then + if [ -x "$(which $1 2>/dev/null)" ]; then echo $1 return fi @@ -141,19 +141,19 @@ searchtool() fi if [ "$(echo $1 | cut -b -3)" = "sha" ]; then if [ $UNAME = "FreeBSD" ]; then - if test -x "$(which sha1 2>/dev/null)"; then + if [ -x "$(which sha1 2>/dev/null)" ]; then echo sha1 return fi fi if [ $UNAME = "NetBSD" ]; then - if test -x "$(which cksum 2>/dev/null)"; then + if [ -x "$(which cksum 2>/dev/null)" ]; then echo cksum -a $(echo $1 | sed -e 's,sum,,') return fi fi if [ $UNAME = "Darwin" ]; then - if test -x "$(which openssl 2>/dev/null)"; then + if [ -x "$(which openssl 2>/dev/null)" ]; then echo openssl $(echo $1 | sed -e 's,sum,,') return fi @@ -188,8 +188,11 @@ download() { printf " * $FILE " test -f tarballs/$FILE && \ - (test -z "$CHECKSUM" || \ - test "$(cat sum/$FILE.cksum 2>/dev/null | sed -e 's,.*\([0-9a-f]\{40\}\).*,\1,')" = "$($CHECKSUM tarballs/$FILE 2>/dev/null | sed -e 's,.*\([0-9a-f]\{40\}\).*,\1,')" ) && \ + ( test -z "$CHECKSUM" || \ + test "$(cat sum/$FILE.cksum 2>/dev/null | \ + sed -e 's,.*\([0-9a-f]\{40\}\).*,\1,')" = \ + "$($CHECKSUM tarballs/$FILE 2>/dev/null | \ + sed -e 's,.*\([0-9a-f]\{40\}\).*,\1,')" ) && \ printf "(cached)" || ( printf "(downloading)" rm -f tarballs/$FILE @@ -200,9 +203,10 @@ download() { (test -z "$CHECKSUM" || $CHECKSUM tarballs/$FILE > sum/$FILE.cksum ) && \ printf "(checksum created. ${RED}Note. Please upload sum/$FILE.cksum if the corresponding archive is upgraded.${NC})" ) - test -f tarballs/$FILE || \ + if [ ! -f tarballs/$FILE ]; then printf "\n${RED}Failed to download $FILE.${NC}\n" - test -f tarballs/$FILE || exit 1 + exit 1 + fi printf "\n" }