Using shell command `which` in a portable way