path for all args except the first. So "which cp vi" found /bin/cp
using the first entry in the path, but failed to find /usr/bin/vi
using the second entry in the path, although "whereis cp vi" worked.
Restoring the ":" was done in the wrong place.
Also fix a bug in which an arg beginning with "/" would cause all
subsequent args to be ignored. A "break" should have been "continue".
Add comments to all break and continue statements saying what they are
intended to do.
Also add braces around the body of a for loop which contained only one
multi-line statement.
- fix bug where if a program appeared in more than one place it would
erroneously exit(2)
- fix error messages to use err and errx as appropriate.
- made sure we don't pick up directories or non executable files.
Submitted by Gabriel Gonzalez in PR bin/20984
I deviated from the patch by returning 2 if only some programs were
located and 3 if none were. The submitted patch returned 1 and 2,
respectively, and 1 is already used for general error.