[coreboot-gerrit] New patch to review for coreboot: c0e8c09 buildgcc: move from if test to if [ .. ]

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Tue Jun 9 22:46:49 CEST 2015


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10485

-gerrit

commit c0e8c0951861fe474c72034fdd99ba6d42a8e61c
Author: Stefan Reinauer <stefan.reinauer at coreboot.org>
Date:   Tue Jun 9 11:50:05 2015 -0700

    buildgcc: move from if test to if [ .. ]
    
    Change-Id: I29fe23e377045f08b8212742d84c2ee2b4a61b15
    Signed-off-by: Stefan Reinauer <stefan.reinauer at coreboot.org>
---
 util/crossgcc/buildgcc | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index a463849..a30ef24 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"
 }
 



More information about the coreboot-gerrit mailing list