Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Aug 2010 13:01:17 -0700
From:      Garrett Cooper <yanegomi@gmail.com>
To:        standards@freebsd.org
Subject:   Re: Confusion over wording in glob(3)
Message-ID:  <AANLkTimWafqB5igfEtd9eGwXLwkrSB15MacBbynw0H7_@mail.gmail.com>
In-Reply-To: <AANLkTinoKOxBxQ0NmXyXvHuTeNQ9Nx=HGgGwb8pAK-xF@mail.gmail.com>
References:  <AANLkTinoKOxBxQ0NmXyXvHuTeNQ9Nx=HGgGwb8pAK-xF@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Aug 2, 2010 at 12:35 AM, Garrett Cooper <yanegomi@gmail.com> wrote:
> =A0 =A0I have some question about the ambiguity of the ERRORS section in
> our glob(3) manpage.
>
> POSIX states:
>
> ERRORS
>
> =A0 =A0The glob() function shall fail and return the corresponding value =
if:
>
> =A0 =A0GLOB_ABORTED
> =A0 =A0 =A0 =A0The scan was stopped because GLOB_ERR was set or (*errfunc=
())
> returned non-zero.
> =A0 =A0GLOB_NOMATCH
> =A0 =A0 =A0 =A0The pattern does not match any existing pathname, and
> GLOB_NOCHECK was not set in flags.
> =A0 =A0GLOB_NOSPACE
> =A0 =A0 =A0 =A0An attempt to allocate memory failed.
>
> (Note that there's no mention of `errno').
> Our manpage states:
>
> =A0 =A0 If glob() terminates due to an error, it sets errno and returns o=
ne of
> =A0 =A0 the following non-zero constants, which are defined in the includ=
e file
> =A0 =A0 <glob.h>:
>
> =A0 =A0 GLOB_NOSPACE =A0An attempt to allocate memory failed, or if errno=
 was 0
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 GLOB_LIMIT was specified in the flags=
 and pglob->gl_matchc
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 or more patterns were matched.
>
> =A0 =A0 GLOB_ABORTED =A0The scan was stopped because an error was encount=
ered and
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 either GLOB_ERR was set or (*errfunc)=
() returned non-zero.
>
> =A0 =A0 GLOB_NOMATCH =A0The pattern did not match a pathname and GLOB_NOC=
HECK was
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 not set.
>
> (Note the mention of errno).
> So far I've only been able to hit a sensical error case once by doing
> the following (but that could have been a side-effect from a malloc(3)
> failure in terms of finding malloc.conf -- don't know for sure). The
> rest of the time I get errno =3D 0:
>
> $ cc -o test_glob test_glob.c
> $ ln -f test_glob test_glob_nomatch
> $ ./test_glob_nomatch
> NOMATCH
> glob(./test_glob_nomatch.*) didn't match: 0: Unknown error: 0
>
> So I suppose my question is: should the confusing wording be removed
> for clarity?

    Looking over the manpages a bit more closely, it might help if I
had specified GLOB_ERR -- but it would help if that was spelled out
more clearly in the manpage (I tend to skim to the bottom of manpages
for the error and return code sections, so I missed that point).
Thanks!
-Garrett



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimWafqB5igfEtd9eGwXLwkrSB15MacBbynw0H7_>