]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - posix/glob.c
When glob pattern contains a trailing slash match only directories. Fixes bug 10278.
[thirdparty/glibc.git] / posix / glob.c
index ece71c168fa05ce0583647617611b469e272d8c6..85237c2a44eafeca141ef4d24b4a41b146b932d7 100644 (file)
@@ -276,6 +276,11 @@ glob (pattern, flags, errfunc, pglob)
       return -1;
     }
 
+  /* POSIX requires all slashes to be matched.  This means that with
+     a trailing slash we must match only directories.  */
+  if (pattern[0] && pattern[strlen (pattern) - 1] == '/')
+    flags |= GLOB_ONLYDIR;
+
   if (!(flags & GLOB_DOOFFS))
     /* Have to do this so `globfree' knows where to start freeing.  It
        also makes all the code that uses gl_offs simpler. */