Use "hash" instead of "which" to find optional programs.