This can be used in setup.sh functions so links are only installed for
applications which exist on the machine.
Also add tests for the function.
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
+}
+
# Creates a symbolic link for file $1 in dirname of $2 with name of basenmae
# $2.
#
--- /dev/null
+
+
+. ../lib.sh
+
+# Tests for installed().
+installed which && echo which installed
+installed doesnt-exist && echo doesnt-exist installed
--- /dev/null
+which installed
--- /dev/null
+#!/bin/sh
+
+# Runs all tests in this directory.
+
+
+# Get all test files.
+for file in *.test; do
+ # Run the test file in sh and zsh and get its output.
+ sh $file > $file.out.sh 2>&1
+ zsh $file > $file.out.zsh 2>&1
+
+ # Check if the output matches the expected one. If not abort with exit
+ # code 1.
+ diff -u -N $file.out $file.out.sh || exit 1
+ diff -u -N $file.out $file.out.zsh || exit 1
+done
+
+# Remove all temporary files.
+rm -rf tmp
+rm *.out.sh
+rm *.out.zsh