Should glob, with GLOB_MARK, add / to the symlink-to-directory results?

The glob function has the GLOB_MARK flag, which is specified to add a slash to the results, which are directories:

GLOB_MARK

Each path name, which is a directory matching the pattern, must contain <slash> .

(Source: http://pubs.opengroup.org/onlinepubs/9699919799/functions/glob.html )

However, as far as I can tell, further details on how this function should work are not given. In particular, if the result is not the directory itself, but a symbolic link to the directory, should you add a slash? The glibc implementation does this.

I know this is a difficult question to answer, given the complexity of the standard for glob , so good answers would be those that refer to historical practice, historical standards or documentation other than POSIX, which can further define the behavior of glob , etc. Answers that cause reasons why one behavior or another is more useful would also be interesting.

+6
source share
1 answer

From my own unofficial research branch of my team :; -)

glob (3) first appeared in bsd4.3-reno in 1989 and added "/" after symbolic links to the directory with GLOB_MARK

http://minnie.tuhs.org/cgi-bin/utree.pl?file=4.3BSD-Reno/src/lib/libc/gen/glob.c

(glob2 uses stat, not lstat on pathbuf)

Solaris has a globe with an author’s commentary from 1985

which appends '/' to symbolic links as well

+1
source

Source: https://habr.com/ru/post/906612/


All Articles