Stephane Chazelas <[email protected]> wrote, on 23 Jul 2019:
>
> 2019-07-23 09:55:52 +0100, Geoff Clare:
> [...]
> > > Why GLOB_ERR? The shell does silently ignore directory open and
> > > read errors when expanding globs. In
> > > 
> > >    ls -ld -- *.c
> > > 
> > > The shell would run ls with a literal *.c as argument without
> > > giving any warning when the current directory is not readable.
> > 
> > The shell should ignore EACCES errors from opendir() (and probably
> > ELOOP, ENAMETOOLONG, ENOENT and ENOTDIR, none of which apply for "*.c")
> > but if opendir() fails with EMFILE or ENFILE the shell should report
> > an error.
> [...]
> 
> EACCES could apply for *.c if the current directory is not
> readable. The other ones could apply for dir/*.c

I think you may have misread what I wrote, because nothing in your
reply disagrees with what I wrote. (Did you miss the parentheses?)

> In any case no shell reports errors upon failing to open or read
> directories when expanding globs (including for EMFILE/ENFILE;
> I'd agree it may be worth notifying the user of this kind of
> pathological condition; but doing it for each opendir in things
> like */*.c would be a problem).

If any shell does not report an error when opendir() returns EMFILE
or ENFILE then that's definitely a bug in that shell.  Silently
executing a command with the unchanged pattern instead of with the
pathnames that match the pattern could have all kinds of consequences.

I would expect a non-interactive shell to exit, and an interactive
shell to stop processing the previous input and write a prompt.

> If the spec says otherwise, it's a bug in the spec.

The spec says "A diagnostic message shall be written to standard error
whenever an error condition occurs."  This is in a bullet list which is
prefaced with "unless otherwise stated", so perhaps we should add
something in 2.13.3, e.g. after:

    Each component that contains a pattern character shall require
    read permission in the directory containing that component. Any
    component, except the last, that does not contain a pattern
    character shall require search permission.

add:

    If these permissions are denied, or if an attempt to open or
    search a directory fails because it does not exist, is not
    a directory, has a too-long name, or would require too many
    symbolic links to be followed, the pattern shall be treated as
    not matching any existing filenames or pathnames and this shall
    not be considered an error.

-- 
Geoff Clare <[email protected]>
The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England

Reply via email to