#!/bin/sh

# find an installed program from a list of possible programs
# output path and exit with success on first match
# no output and exit with failure if no match

if [ "$#" -lt 1 ]; then
	echo "$0: missing arguments" > /dev/stderr
	exit 2
fi

unset found
for i in "$@" ; do
        found=$(which "$i" 2>/dev/null ) && break
done

if [ -n "$found" ]; then
	# print name, exit with success
	echo "$found"
	exit 0
else
	# be silent, exit with failure
	exit 1
fi
