[PATCH] Detect location of `ldconfig' before use

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Sun Feb 5 03:53:38 PST 2017


The unhandled error was:

	./subsurface/scripts/build.sh: line 84: ldconfig: command not found

On my box, the path is /sbin/ldconfig, and /sbin is not in common users'
PATH.

The script just continued to execute after that error, which can result
in other odd bugs showing up later.  That's the reason shell option
'-e' (errexit) was introduced.

Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>
---
 scripts/build.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/scripts/build.sh b/scripts/build.sh
index f60d7045..cf87f26b 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -16,6 +16,8 @@
 # of the current directory (except on Mac where the Subsurface.app ends up
 # in subsurface/build
 
+set -e
+
 # create a log file of the build
 exec 1> >(tee build.log) 2>&1
 
@@ -81,7 +83,11 @@ else
 	# check if we need to build libgit2 (and do so if necessary)
 
 	LIBGIT_ARGS=" -DLIBGIT2_DYNAMIC=ON "
-	LIBGIT=$(ldconfig -p | grep libgit2\\.so\\. | awk -F. '{ print $NF }')
+	_ldconfig=$(PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH command -v ldconfig) || {
+		echo "can't find ldconfig" >&2
+		exit 1
+	}
+	LIBGIT=$($_ldconfig -p | grep libgit2\\.so\\. | awk -F. '{ print $NF }')
 fi
 
 if [[ $PLATFORM = Darwin || "$LIBGIT" < "24" ]] ; then
-- 
2.11.0



More information about the subsurface mailing list