tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: glob(3) GLOB_PERIOD bug?

>> It looks to me as though there's a bug in glob(3)'s GLOB_PERIOD.

> Perhaps the man page is not clear; with GLOB_PERIOD a leading period
> in a filename can be matched with a globbing character, without it
> does not.

That's approximately what I thought.

So how does ../? match ../X and ../Y without GLOB_PERIOD, but nothing
at all with?  Seems to me GLOB_PERIOD should only increase the list of
things matched (by adding components beginning with dots to the list of
potential matches for each wildcard).

>       h = getenv("HOME");
>       h = h ? h : ".";
>       snprintf(gpath, sizeof(gpath), "%s/?*", h);
>       rv = glob(gpath, f, gerr, &g);

Both versions work fine in this case.  I'm not sure how this is
relevant.  WIth the program as I posted it, I see output like

flags = 0:
  pathc=2 matchc=2
    [0] ../X
    [1] ../z
flags = GLOB_PERIOD:

How can that be correct?  With my fix, ie, after backing out the change
I cited, I get

flags = 0:
  pathc=2 matchc=2
    [0] ../X
    [1] ../z
flags = GLOB_PERIOD:
  pathc=3 matchc=3
    [0] ../.
    [1] ../X
    [2] ../z

which as far as I can see is exactly how it should behave.

Your test gives me the same output either way, so I'm not sure what
your point is.  Showing that the code works fine in case B doesn't have
any bearing on whether the behaviour in case A indicates a bug.

If you want to argue that GLOB_NOMATCH is the correct behaviour for
../? with GLOB_PERIOD set, fine, I'm willing to listen (though I'll
take a lot of convincing, especially given what prompted me to add it
in the first place; the semantics I wanted were "GLOB_PERIOD means
leading dots are no longer in any way special").  But that's not what I
see you arguing here.  What I see amounts to something akin to replying
to "rename() crashes in this case!" with "No problem, it works fine in
this other case!"

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML      
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

Home | Main Index | Thread Index | Old Index