]> ruderich.org/simon Gitweb - config/dotfiles.git/commitdiff
Fix installed() in setup.sh on Mac OS X.
authorSimon Ruderich <simon@ruderich.org>
Tue, 24 Feb 2009 20:18:35 +0000 (21:18 +0100)
committerSimon Ruderich <simon@ruderich.org>
Tue, 24 Feb 2009 20:25:45 +0000 (21:25 +0100)
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
tests/lib.sh.test
tests/lib.sh.test.out

diff --git a/lib.sh b/lib.sh
index 31b56c066db9596df61488efd4e7a48a6c8cbeae..5576bce23beab7f48e6cbd989ea6c243cb04a2b5 100644 (file)
--- 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
index d21ee2dfd3092bfeda519e43857c73999bcfbd44..03184a01461371823de8a7b483faa00b0f1463ec 100644 (file)
@@ -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
index 79a69a081cd5a1bdc9c7f5e95dadd71f3610a8b5..faa564df4b699bb938917b20eea9c785894806f2 100644 (file)
@@ -1 +1 @@
-which installed
+ls installed