aboutsummaryrefslogtreecommitdiff
path: root/contrib/shunit2-2.0.3/bin/which
diff options
context:
space:
mode:
authorPjotr Prins2017-08-20 09:22:43 +0000
committerPjotr Prins2017-08-20 09:22:43 +0000
commit2e76646998df0ca1b7d160329c0f3ac8cdda2fe0 (patch)
tree8a1ba0770e2344469c58290d4192db186d9439cb /contrib/shunit2-2.0.3/bin/which
parent7fc4e3c0a0d6e32ca6685647e107473f1d96c3e5 (diff)
downloadpangemma-2e76646998df0ca1b7d160329c0f3ac8cdda2fe0.tar.gz
Move shunit2 into ./contrib and add catch-1.8.7
Diffstat (limited to 'contrib/shunit2-2.0.3/bin/which')
-rwxr-xr-xcontrib/shunit2-2.0.3/bin/which36
1 files changed, 36 insertions, 0 deletions
diff --git a/contrib/shunit2-2.0.3/bin/which b/contrib/shunit2-2.0.3/bin/which
new file mode 100755
index 0000000..9d7cc9f
--- /dev/null
+++ b/contrib/shunit2-2.0.3/bin/which
@@ -0,0 +1,36 @@
+#! /bin/sh
+# $Id$
+#
+# This is a simple implementation of the 'which' command for those OSes that
+# don't have one.
+#
+
+true; TRUE=$?
+false; FALSE=$?
+
+showAll=${FALSE}
+
+# process command line flags
+while getopts 'a' opt; do
+ case ${opt} in
+ a) showAll=${TRUE}
+ esac
+done
+shift `expr ${OPTIND} - 1`
+
+# exit if no arguments were given
+[ $# -eq 0 ] && exit 1
+
+command=$1
+
+# search for command
+out=`echo "${PATH}" |sed "s/:/\n/g" |\
+while read path; do
+ fullPath="${path}/${command}"
+ if [ -x "${fullPath}" ]; then
+ echo "${fullPath}"
+ [ ${showAll} -eq ${FALSE} ] && break
+ fi
+done`
+[ -z "${out}" ] && exit 1
+echo "${out}"