Earlier quoted context omitted.
Wtf. TIL about hash.
Using "hash" is arguably the best way to determine if a command is available in a BASH script e.g. hash java 2>/dev/null || printf "java command not available\n"
command -v java >/dev/null || echo 'no java command in path'
...and of course, if you're going to run the command anyway, and you know an invocation that does nothing and always exits with success, you can do that too. I like doing running "--version" or equivalent in CI systems, because it has the side effect of printing what actual versions were in use during the run. java -version || { echo >&2 'no java command in path'; exit 1; }
git --version || { echo >&2 'no git command in path'; exit 1; }
gcc --version || { echo >&2 'no gcc command in path'; exit 1; }