Sources Bugzilla – Bug 1062
sysdeps/generic/glob.c merge from gnulib (part 3 of 3)
Last modified: 2007-09-24 18:29: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>.
Created attachment 554 [details] sysdeps/generic/glob.c merge from gnulib (part 3 of 3)
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.
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.
Nothing happened in more than a year.
Why in the world would you want to ship a glob that cannot pick up broken symlinks?
The code is correct as siad many times before.
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?