diff options
author | Peter Carbonetto | 2017-07-18 12:56:21 -0500 |
---|---|---|
committer | Peter Carbonetto | 2017-07-18 12:56:21 -0500 |
commit | 66e2499abdeb663034721425ad6e8efb3340ad99 (patch) | |
tree | 488cd3c971985fcc66579539e2704bb2641aadc4 /shunit2-2.0.3/bin/which | |
parent | 9c718e1730ffdc78a9154f227250799ab52f7dfa (diff) | |
download | pangemma-66e2499abdeb663034721425ad6e8efb3340ad99.tar.gz |
Added shunint2 v2.0.3 files.
Diffstat (limited to 'shunit2-2.0.3/bin/which')
-rwxr-xr-x | shunit2-2.0.3/bin/which | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/shunit2-2.0.3/bin/which b/shunit2-2.0.3/bin/which new file mode 100755 index 0000000..9d7cc9f --- /dev/null +++ b/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}" |