Treat empty PATH elements as "." for tradition and consistency with the

old Perl which(1) script.

PR:		35719
This commit is contained in:
tjr 2002-06-30 05:48:50 +00:00
parent beba9fcf0e
commit 825f2f17f4

View File

@ -126,13 +126,15 @@ static int
print_matches(char *path, char *filename)
{
char candidate[PATH_MAX];
char *d;
const char *d;
int found;
if (*filename == '/')
return (is_there(filename) ? 0 : -1);
found = 0;
while ((d = strsep(&path, ":")) != NULL) {
if (*d == '\0')
d = ".";
if (snprintf(candidate, sizeof(candidate), "%s/%s", d,
filename) >= (int)sizeof(candidate))
continue;