I am writing a script that will run several versions of a program written in different languages so it should be able to detect if the system can run a file first. I found this question somewhat useful, but I would like to know if my existing code could be improved instead.
I use the following approach to check if a program exists.
if type "$PROGRAM" >/dev/null 2>&1; then
# OK
fi
I was debating whether this question should go in Code Review, but I decided to post it here as it's just 2 lines of code.