aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/which/which.c
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2002-06-30 05:48:50 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2002-06-30 05:48:50 +0000
commit8c821782f8ae62a05cccbb092a3fa8730d4a0bdb (patch)
treec7f042b4f901db695ae0ca8ac7349c6a1aa841a1 /usr.bin/which/which.c
parenta19d42939845e7c55e1ae8c901385271eba3315c (diff)
downloadsrc-8c821782f8ae62a05cccbb092a3fa8730d4a0bdb.tar.gz
src-8c821782f8ae62a05cccbb092a3fa8730d4a0bdb.zip
Treat empty PATH elements as "." for tradition and consistency with the
old Perl which(1) script. PR: 35719
Notes
Notes: svn path=/head/; revision=99118
Diffstat (limited to 'usr.bin/which/which.c')
-rw-r--r--usr.bin/which/which.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/which/which.c b/usr.bin/which/which.c
index cea0ce676f2f..11f43fcb700f 100644
--- a/usr.bin/which/which.c
+++ b/usr.bin/which/which.c
@@ -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;