On Thu, Dec 10, 2020 at 10:35:08PM +1100, Herbert Xu wrote: > Yes but it's really a bug in glob(3). It should really return > a no-match for the case in question, rather than matching and then > returning a filename without the slash. > > IOW the pattern "foo\/" should not match a regular file foo. > > Note that the problem doesn't occur for "foo/". It seems like it happens for "foo/", too. If I compile: -- >8 -- #include <glob.h> #include <stdio.h> int main(int argc, const char **argv) { while (*++argv) { glob_t r; if (glob(*argv, 0, NULL, &r)) perror(*argv); else { size_t i; for (i = 0; i < r.gl_pathc; i++) printf("%s -> %s\n", *argv, r.gl_pathv[i]); globfree(&r); } } return 0; } -- >8 -- I get: $ rm -f foo bar $ touch foo $ ./a.out foo foo/ 'foo\/' bar bar/ 'bar\/' foo -> foo foo/ -> foo foo\/ -> foo bar: No such file or directory bar/: No such file or directory bar\/: No such file or directory -Peff