linux – 为什么glob lstat匹配条目?

this question中查看行为时,我惊讶地看到perl lstat()s每个路径都匹配一个glob模式:
$mkdir dir
$touch dir/{foo,bar,baz}.txt  
$strace -e trace=lstat perl -E 'say $^V; <dir/b*>' 
v5.10.1
lstat("dir/baz.txt",{st_mode=S_IFREG|0664,st_size=0,...}) = 0
lstat("dir/bar.txt",...}) = 0

我在我的Linux系统上看到了与glob(模式)和< pattern>以及更高版本的perl相同的行为.

我的期望是,globbing只是opendir / readdir,并且它不需要检查它正在搜索的实际路径名.

这个lstat的目的是什么?它会影响glob()的返回吗?

解决方法

这个奇怪的行为已经是 noticed before on PerlMonks.事实证明,glob调用lstat来支持它的 GLOB_MARK标志,其结果是:

Each pathname that is a directory that matches the pattern has a slash appended.

要确定目录条目是否引用了子目录,您需要对其进行统计.即使没有给出标志,这显然已经完成.

相关文章

1、安装Apache。 1)执行如下命令,安装Apache服务及其扩展包...
一、先说一下用ansible批量采集机器信息的实现办法: 1、先把...
安装配置 1. 安装vsftpd 检查是否安装了vsftpd # rpm -qa | ...
如何抑制stable_secret读取关键的“net.ipv6.conf.all.stabl...
1 删除0字节文件 find -type f -size 0 -exec rm -rf {} ...
## 步骤 1:安装必要的软件包 首先,需要确保系统已安装 `dh...