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. 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. (but again, there's the problem of lstat() failures that are not reported, but that's a different problem). -- Stephane