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

old Perl which(1) script.

PR:		35719
This commit is contained in:
Tim J. Robbins 2002-06-30 05:48:50 +00:00
parent a19d429398
commit 8c821782f8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=99118

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;