The matching in -lname and -ilname are on the contents of the link
itself, not on the type of the file. As such, do a readlink to get the symbolic link's contents and fail to match if the path isn't a symbolic link. Pointed out by: des@
This commit is contained in:
parent
c2602b5b06
commit
acebb585f7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=176497
@ -1087,9 +1087,16 @@ c_ls(OPTION *option, char ***argvp __unused)
|
||||
int
|
||||
f_name(PLAN *plan, FTSENT *entry)
|
||||
{
|
||||
if ((plan->flags & F_LINK) && !S_ISLNK(entry->fts_statp->st_mode))
|
||||
return 0;
|
||||
return !fnmatch(plan->c_data, entry->fts_name,
|
||||
char fn[PATH_MAX];
|
||||
const char *name;
|
||||
|
||||
if (plan->flags & F_LINK) {
|
||||
name = fn;
|
||||
if (readlink(entry->fts_path, fn, sizeof(fn)) == -1)
|
||||
return 0;
|
||||
} else
|
||||
name = entry->fts_name;
|
||||
return !fnmatch(plan->c_data, name,
|
||||
plan->flags & F_IGNCASE ? FNM_CASEFOLD : 0);
|
||||
}
|
||||
|
||||
@ -1102,8 +1109,6 @@ c_name(OPTION *option, char ***argvp)
|
||||
pattern = nextarg(option, argvp);
|
||||
new = palloc(option);
|
||||
new->c_data = pattern;
|
||||
if (new->flags & F_LINK)
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
return new;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user