This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] posix: if glob has a trailing slash match directories only.
- From: Dmitry Goncharov <dgoncharov at users dot sf dot net>
- To: Paul Eggert <eggert at cs dot ucla dot edu>, libc-alpha at sourceware dot org
- Date: Wed, 29 Nov 2017 16:50:56 -0500
- Subject: Re: [PATCH] posix: if glob has a trailing slash match directories only.
- Authentication-results: sourceware.org; auth=none
- References: <20171128210857.GC2745@madrid> <a97c9749-5bcd-0292-9eae-bd7c4c59ab09@cs.ucla.edu> <20171129042114.GA2702@madrid> <dec247a8-a079-ccde-89da-f7dd6b572604@cs.ucla.edu> <CAG+Z0CsgP0sMTtaurAF8kXJ0HSqhPMC-BxS36=OB05GNUo9xSQ@mail.gmail.com>
On Wed, Nov 29, 2017 at 1:35 AM, Paul Eggert <eggert@cs.ucla.edu> wrote:
>>
>> Thanks for clarifying. Now that I understand it better, though, I still see a problem. As noted in the Glibc manual here:
>>
>> https://www.gnu.org/software/libc/manual/html_node/More-Flags-for-Globbing.html#index-GLOB_005fONLYDIR
>>
>> GLOB_ONLYDIR is merely an efficiency flag: it means "do not return entries that can easily be shown to be non-directories". Your patch would change the semantics of GLOB_ONLYDIR so that it means "return only entries that are known to be directories", which differs from the Glibc documentation.
>>
>>
>>
> You are right. There is indeed this semantics.
The patch is compatible with "do not return entries that can easily be
shown to be non-directories".
One option is we can decide the patch is compatible and apply it.
If the existing semantics has to be preserved then we can introduce
another flag and use the new flag instead of GLOB_ONLYDIR in
if (pattern[0] && pattern[strlen (pattern) - 1] == '/')
flags |= GLOB_ONLYDIR;
and everywhere else where required.
regards, Dmitry