Hi Thierry,
First of all, thanks for the patch! I had noticed this problem when running edksetup.sh on a POSIX but not quite Linux system before.
I kind of dislike your solution. Does NetBSD ship /bin/which by default? I think replacing whereis with "which -a" would be a lot better.
I don't think there's a 100% standard way to do this in POSIX, as which isn't POSIX either, and your solution seems... hacky?
Also, please send patches in the standard git format (git commit -s + git format-patch + git send-email with the proper CCs to the maintainers, see the proper guides for more details).