glob 是否应该使用 GLOB_MARK 将 / 附加到符号链接到目录结果?
glob
函数有一个 GLOB_MARK
标志,指定将斜杠附加到目录结果中:
GLOB_MARK
作为与模式匹配的目录的每个路径名都应附加一个
。
(来源:http://pubs.opengroup.org/onlinepubs/9699919799/functions/ glob.html)
但是,据我所知,没有提供有关此功能如何工作的更多详细信息。特别是,如果结果本身不是目录,而是目录的符号链接,是否应该附加斜杠? glibc 实现就是这样做的。
我知道鉴于 glob
标准的简洁性,这是一个很难回答的问题,因此好的答案是引用 POSIX 之外的历史实践、历史标准或文档,这些文档可能会进一步指定 glob 的行为glob 等。提出一种行为或另一种行为更有用的原因的答案也会很有趣。
The glob
function has a GLOB_MARK
flag that's specified to append a slash to results which are directories:
GLOB_MARK
Each pathname that is a directory that matches pattern shall have a
<slash>
appended.
(Source: http://pubs.opengroup.org/onlinepubs/9699919799/functions/glob.html)
However, as far as I can tell, no further details are provided on how this feature is supposed to work. In particular, if a result is not a directory itself, but is a symbolic link to a directory, should a slash be appended? The glibc implementation does this.
I know this is a hard question to answer given the terseness of the standard for glob
, so good answers will be ones that cite historical practice, historical standards or documentation other than POSIX that might further specify the behavior of glob
, etc. Answers which bring up reasons why one behavior or the other is more useful would also be interesting.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自我自己团队的非官方研究分支:;-)
From my own team's unofficial research branch: ;-)