[coreboot-gerrit] Change in coreboot[master]: crossgcc/buildgcc: update file location code

Martin Roth (Code Review) gerrit at coreboot.org
Thu Jun 15 19:36:44 CEST 2017


Martin Roth has uploaded this change for review. ( https://review.coreboot.org/20230


Change subject: crossgcc/buildgcc: update file location code
......................................................................

crossgcc/buildgcc: update file location code

- Change from 'which' to 'command -v'. Which is not a posix command.
- When testing to see if gnat1 is executable, don't try to test it
in the current directory - try to test it in the path instead.

Change-Id: Icdf18e7e496447157554b8e61b1528f03456536d
Signed-off-by: Martin Roth <martinroth at google.com>
---
M util/crossgcc/buildgcc
1 file changed, 7 insertions(+), 7 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/30/20230/1

diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index 63abc59..51028d1 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -149,7 +149,7 @@
 		search="$2"
 	fi
 	for i in "$1" "g$1" "gnu$1"; do
-		if [ -x "$(which $i 2>/dev/null)" ]; then
+		if [ -x "$(command -v $i 2>/dev/null)" ]; then
 			if [ "$(cat /dev/null | $i --version 2>&1 | grep -c "$search")" \
 			    -gt 0 ]; then
 				echo $i
@@ -161,7 +161,7 @@
 	# 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 [ -x "$(which $1 2>/dev/null)" ]; then
+			if [ -x "$(command -v $1 2>/dev/null)" ]; then
 				echo $1
 				return
 			fi
@@ -169,19 +169,19 @@
 	fi
 	if echo $1 | grep -q "sum" ; then
 		algor=$(echo $1 | sed -e 's,sum,,')
-		if [ -x "$(which $1 2>/dev/null)" ]; then
+		if [ -x "$(command -v $1 2>/dev/null)" ]; then
 			#xxxsum [file]
 			echo $1
 			return
-		elif [ -x "$(which $algor 2>/dev/null)" ]; then
+		elif [ -x "$(command -v $algor 2>/dev/null)" ]; then
 			#xxx [file]
 			echo $algor
 			return
-		elif [ -x "$(which openssl 2>/dev/null)" ]; then
+		elif [ -x "$(command -v openssl 2>/dev/null)" ]; then
 			#openssl xxx [file]
 			echo openssl $algor
 			return
-		elif [ -x "$(which cksum 2>/dev/null)" ]; then
+		elif [ -x "$(command -v cksum 2>/dev/null)" ]; then
 			#cksum -a xxx [file]
 			#cksum has special options in NetBSD. Actually, NetBSD will use the second case above.
 			echo "buildgcc" | cksum -a $algor > /dev/null 2>/dev/null && \
@@ -232,7 +232,7 @@
 }
 
 hostcc_has_gnat1() {
-	[ -x "$(${CC} -print-prog-name=gnat1)" ]
+	[ -x $(command -v "$(${CC} -print-prog-name=gnat1 2>/dev/null)") ]
 }
 
 ada_requested() {

-- 
To view, visit https://review.coreboot.org/20230
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icdf18e7e496447157554b8e61b1528f03456536d
Gerrit-Change-Number: 20230
Gerrit-PatchSet: 1
Gerrit-Owner: Martin Roth <martinroth at google.com>



More information about the coreboot-gerrit mailing list