From: Simon Ruderich Date: Tue, 24 Feb 2009 20:18:35 +0000 (+0100) Subject: Fix installed() in setup.sh on Mac OS X. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=4cb251564b860a64b316aba2cb3ab376ce6c36de;p=config%2Fdotfiles.git 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. --- 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