programpath=$(which whatever 2> /dev/null) if test -z "$programpath"; then echo "program doesn't exist" exit fi