#########################################################################
#
# Subroutines for determining existence of / path to executables
#
#########################################################################

findEXE() {
    if test $# -lt 1
    then
	printFATAL "findEXE: insufficient arguments"
    fi

    X="$PATH";
    prog="$1";
    OLD_IFS=${IFS}
    IFS=':'; export IFS 
    for dir in $X; do
	exe="$dir/$1"
	if (test -f "$exe" || test -f "${exe}.exe")
	then
	    EXECUTABLE="$exe"; export EXECUTABLE
	    IFS=${OLD_IFS}; export IFS
	    return 0
	fi
    done
    IFS=${OLD_IFS}; export IFS
    printINFO "Command $1 not found in \$PATH"
    EXECUTABLE=""; export EXECUTABLE
}

needEXE() {
    # printINFO "Checking for $@"
    for arg
    do
	findEXE "$arg"
	test -z "$EXECUTABLE" && printFATAL "Need \"$arg\" in \$PATH"
    done
    return 0
}
