Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Unreadable directories aren't included in glob expansion



Consider:

% mkdir foo
% mkdir -m 000 bar 
% echo */ 
foo/
% echo *(/)
bar foo
% 

Shouldn't the expansion of «*/» include «bar/»?

The shell knows, in that situation, that ./bar is a directory; «test -d bar»
and «zstat -or bar» both confirm this.

dash/bash/ksh all include «bar/» in that expansion.  

strace shows a probable cause:
.
    access("buster/.", F_OK)                = -1 EACCES (Permission denied)

I've discussed this on IRC with Eric, but I'd rather let him explain his view
in his own words.

Cheers,

Daniel

P.S. Test case:

diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst
index 5638e1255..1c1663a48 100644
--- a/Test/D02glob.ztst
+++ b/Test/D02glob.ztst
@@ -728,3 +728,10 @@
 >does/not/exist
 >not/exist
 >exist
+
+ mkdir -m 000 glob.tmp/secret1
+ (setopt nullglob
+  echo glob.tmp/*/ glob.tmp/*(/)
+  )
+-f:unreadable directories can be globbed
+>glob.tmp/secret1/ glob.tmp/secret1



Messages sorted by: Reverse Date, Date, Thread, Author