Use command -v to test command existence

Use preferred POSIX `command -v` test for command existence instead of
previous `which` technique. `which` exits with status `1` if nothing is
found. That would cause the script to abort because we use `set -e`.

http://stackoverflow.com/questions/592620/how-to-check-if-a-program-exists-from-a-bash-script