From 4cb251564b860a64b316aba2cb3ab376ce6c36de Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Tue, 24 Feb 2009 21:18:35 +0100 Subject: [PATCH] Fix installed() in setup.sh on Mac OS X. which on Mac OS X doesn't use proper exit code. Also test for ls instead of which as it caused problems. I have no idea why. --- lib.sh | 2 +- tests/lib.sh.test | 2 +- tests/lib.sh.test.out | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib.sh b/lib.sh index 31b56c0..5576bce 100644 --- a/lib.sh +++ b/lib.sh @@ -14,7 +14,7 @@ m4=`which m4` # Check if the given program is installed. Returns 0 if it exists, 1 # otherwise; so it can be used in if. installed() { - which $1 > /dev/null + which $1 | grep -E '^/' > /dev/null } # Creates a symbolic link for file $1 in dirname of $2 with name of basenmae diff --git a/tests/lib.sh.test b/tests/lib.sh.test index d21ee2d..03184a0 100644 --- a/tests/lib.sh.test +++ b/tests/lib.sh.test @@ -3,5 +3,5 @@ . ../lib.sh # Tests for installed(). -installed which && echo which installed +installed ls && echo ls installed installed doesnt-exist && echo doesnt-exist installed diff --git a/tests/lib.sh.test.out b/tests/lib.sh.test.out index 79a69a0..faa564d 100644 --- a/tests/lib.sh.test.out +++ b/tests/lib.sh.test.out @@ -1 +1 @@ -which installed +ls installed -- 2.45.2