From 1a248e48683e44ed20fa44c29c1fdf6aedc40bfd Mon Sep 17 00:00:00 2001 From: Marco Molteni Date: Mon, 17 Aug 2020 03:37:12 +0200 Subject: [PATCH] Fix: build.sh: give validateToolPresence a chance to inform the user (#9776) Since the build.sh script runs with `set -e` (exit _immediately_ in case of error), we cannot first call the `which` command and, on a susequent line, check its exit status with $?, it would be too late. Instead, we idiomatically check on the same line of the invocation of `which`. From the confusing: $ make bin ==> Checking for necessary tools... make: *** [bin] Error 1 To the informative: $ make bin ==> Checking for necessary tools... realpath is not on the path. Exiting... make: *** [bin] Error 1 --- scripts/build.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index ac3a5dbac..e16152e6f 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -13,8 +13,7 @@ set -e function validateToolPresence { local TOOLNAME=$1 - which ${TOOLNAME} >/dev/null - if [ $? -ne 0 ]; then + if ! which ${TOOLNAME} >/dev/null; then echo "${TOOLNAME} is not on the path. Exiting..." exit 1 fi