Stephane Chazelas <stephane.chaze...@gmail.com> wrote, on 29 Jul 2019:
>
> 2019-07-29 11:43:11 +0100, Geoff Clare:
> [...]
> > > But here I'm saying that the ENOENT/ENOTDIR errors should be
> > > ignored with GLOB_ERR. It can already be implied to some extent
> > > in that if you get those errors then it's not "directories"
> > > you're trying to open (so it's not a case there "it encounters a
> > > *directory* that it cannot open or read), but still the Solaris
> > > implementation (for both ENOENT and ENOTDIR) and GNU
> > > implementations (for ENOENT) still return errors.
> > 
> > I think you're interpreting the current text too literally. My
> > reading is that it is trying to describe what happens when glob()
> > attempts to open what it expects to be a directory and gets an error.
> > The Solaris behaviour seems like the right thing to do.  If an
> > application calls glob() to expand /etc/passwd/*.c without GLOB_NOCHECK
> > and with GLOB_ERR then I think the application writer would want glob()
> > to indicate that there's a problem with the pattern, not just that there
> > are no matches.
> [...]
> 
> But then
> 
> in */*.c, Solaris returns with an error if the current directory
> contains a non-directory file (and calls errfunc() with ENOTDIR
> and that file), which is not wanted.

True, but there's no way round that because GLOB_ERR can't distinguish
these cases.  It's "all or nothing".  

> IMO, GLOB_ERR should be about failure to expand the glob.
> The ENOTDIR error when expanding /etc/passwd/*.c is not
> preventing the glob from expanding (to nothing). If passwd was a
> symlink to some inaccessible area, then it would.

To me the point of having GLOB_ERR and errfunc as two different
error reporting mechanisms is that GLOB_ERR is "all or nothing"
and errfunc lets you be more selective.  You said yourself in the bug
that the Solaris behaviour is "more flexible in that the caller can
use a errfunc that ignores ENOENT/ENOTDIR to emulate the GNU/FreeBSD
behaviour".

-- 
Geoff Clare <g.cl...@opengroup.org>
The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England

Reply via email to