Use `type -p` instead of `which`

On some systems, `which` requires an additional package to be
installed. In contrast, `type` is built into `bash`.