Bug 1062 - sysdeps/generic/glob.c merge from gnulib (part 3 of 3)
Summary: sysdeps/generic/glob.c merge from gnulib (part 3 of 3)
Status: REOPENED
Alias: None
Product: glibc
Classification: Unclassified
Component: glob (show other bugs)
Version: 2.3.5
: P2 normal
Target Milestone: ---
Assignee: Roland McGrath
URL:
Keywords:
Depends on: 1060
Blocks:
  Show dependency treegraph
 
Reported: 2005-07-12 07:15 UTC by Paul Eggert
Modified: 2015-08-27 22:02 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
sysdeps/generic/glob.c merge from gnulib (part 3 of 3) (1.67 KB, patch)
2005-07-12 07:15 UTC, Paul Eggert
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Eggert 2005-07-12 07:15:00 UTC
Attached is the most interesting of the 3 patches.  It contains (1) an
efficiency improvement and (2) a related bug fix.

   1. Moves the check for GLOB_MARK directory status (and the append of
      `/') into glob_in_dir, where it is more efficient than performing
      a second pass through the data and sometimes calling stat a second
      time on each file or directory.  All calls to stat are avoided
      when dirent->d_type is available.  No call to realloc of the
      directory name is ever necessary since room for the slash can be
      allocated in the first pass.

   2. Ignores broken links only when GLOB_ONLYDIR is set.  With glibc
      versions 2.3.3 through 2.3.5, the following in an empty directory
      would return nothing:

          ln -s doesnt-exist linkname
          glob ("*", ...)

      This fix syncs with the comments in the file, syncs with the
      POSIX 1003.2 spec, syncs with the BSD behavior, restores the
      pre-glibc-2.3.3 behavior, and simply makes more sense - why should
      `rm *' fail to remove broken links?  This certainly deviates from
      historical practice and the behavior most likely expected by a
      user.

      There is further discussion of this issue and why this is the
      correct fix here:
      <http://lists.gnu.org/archive/html/bug-cvs/2005-06/msg00004.html>
      and here:
      <https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=126460>.
Comment 1 Paul Eggert 2005-07-12 07:15:45 UTC
Created attachment 554 [details]
sysdeps/generic/glob.c merge from gnulib (part 3 of 3)
Comment 2 Ulrich Drepper 2005-09-17 18:12:58 UTC
The broken link behavior is correct, makes the code consistent with itself, and
brings it in line with other implementations.  Whatever BSD does is irrelevant.

And due to your inability to keep changes separated I cannot look at the other
change.  Separate out the other patch and I will look at it.
Comment 3 Roland McGrath 2006-01-11 05:33:10 UTC
Please separate your changes and submit the internal cleanup or performance
improvement changes separately from any changes to semantics (which are always
likely to be controversial).  The first part of the change sounds worthwhile,
but it should not be conflated with the second change.  Please send a patch
freshly made against the most current glibc cvs posix/glob.c.
Comment 4 Ulrich Drepper 2007-04-28 06:39:20 UTC
Nothing happened in more than a year.
Comment 5 Derek Price 2007-04-28 13:49:38 UTC
Why in the world would you want to ship a glob that cannot pick up broken symlinks?
Comment 6 Ulrich Drepper 2007-09-23 22:57:09 UTC
The code is correct as siad many times before.
Comment 7 Derek Price 2007-09-24 18:29:00 UTC
Yes, changes to semantics are likely to be controversial and I am very sorry I
missed my chance to say something BEFORE GLIBC's glob was altered to stop
matching "*" to broken symlinks, counter to the POSIX specification.

Now that it has been changed, I am very interested in participating in a
discussion about changing it back.  Could you direct me to the correct list and
could we have it out in a larger forum before closing this issue again?

Would it be an acceptable compromise if I was to alter and resubmit the attached
patch such that glob would only exhibit the POSIX behavior when GLOB_POSIX,
GLOB_BROKEN_SYMLINKS, or some other such flag is passed in?