2019-08-01 15:51:10 +0100, Geoff Clare:
> Stephane Chazelas <stephane.chaze...@gmail.com> wrote, on 01 Aug 2019:
> >
> > It's also not clear what the interaction between GLOB_MARK and
> > GLOB_NOCHECK would be. If a pattern expands to itself because it
> > can't find a match, should it still call stat on it?
> 
> Not clear?  Seems crystal clear to me.
> 
> GLOB_NOCHECK: "... shall return a list consisting of only pattern".
> No allowance for a slash to be appended.
> 
> GLOB_MARK: "Each pathname that is a directory that matches pattern ..."
> If pattern does not match anything, then it is not "a directory that
> matches pattern" even if a directory with the same name exists.
[...]

Makes sense, though in my example the pathname *did* match the
pattern. Only that unreadable/* file was not found by glob() as
the unreadable directory wasn't readable. It was searchable
though which meant a stat on the "unreadable/*" directory
succeeded.

In any case, those implementations will happily add a / even on
directories that don't match the pattern like in unreadable/[*]
or unreadable/\*, so those implementations are not compliant.

Related question, also related to the backslash issue
(bugid:1234). In:

glob("\\foo")

Should glob look for foo in the current directory via a listing of
it or via lstat("foo")?

Looking at the glibc implementation, I see that glob("foo") does
a lstat("foo") without NOCHECK and nothing at all with NOCHECK.
While for glob("\\foo"), it searches for it in the directory
listing (both with and without NOCHECK). The MARK is added based
on a stat() done on the result of the expansion (with NOCHECK,
either foo or \foo). IOW, it behaves the same as for
glob("[f]oo").

-- 
Stephane

Reply via email to