Use `type -p` instead of `which` (see #6128)