Do not rely on "type -p"

Apparently dash (used as bin/sh on Ubuntu) does not support type -p.

Thanks to Esben Madsen for noticing and suggesting a fix.