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.
# 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
. ../lib.sh
# Tests for installed().
-installed which && echo which installed
+installed ls && echo ls installed
installed doesnt-exist && echo doesnt-exist installed
-which installed
+ls installed