> I think that which exits with status 1 if nothing is found. Won't that cause the script to abort because we use set -e?

`errexit` only triggers *un-handled* exit statuses.

```sh
foo() { return 1; }

set -e

if ! foo; then
  echo "Will see me"
fi

foo || echo "Will see me too"

foo # will trigger exit

echo "Won't see me"
```

> I think you want to use type, hash, or command instead: http://stackoverflow.com/questions/592620/how-to-check-if-a-program-exists-from-a-bash-script

Yes it is recommended to avoid `which`.

From the bot in `#bash`:

> which(1) is an external program used to search PATH for an executable. It behaves
> differently on different systems and you can't rely on a useful exit code; use
> (from most to least portable) ''command -v'' or ''type -P'' (to find the path) or
> ''hash'' (to check) instead. See http://mywiki.wooledge.org/BashFAQ/081

I'm bad about this guideline myself, mostly because I can never remember the arguments to `command` or `type` to use in this case.