From: Guillaume Cottenceau Date: 2001-05-26T07:23:45+09:00 Subject: [ruby-talk:15738] Ruby globbing problem? I have two directories, one being a "real" directory, the other one being a symlink to another directory. It seems that Ruby will have some problems globbing with Dir#[] when a symlink is in the way, while Dir#entries and Dir#open/each seem to work.. quite strange. In irb: irb(main):001:0> Dir.entries("/mnt").size 7 irb(main):002:0> Dir.entries("/SRPMS").size 1117 irb(main):003:0> Dir["/mnt/*"] ["/mnt/cdrom", "/mnt/nfs", "/mnt/disk", "/mnt/floppy", "/mnt/distrib"] irb(main):004:0> Dir["/SRPMS/*"] [] irb(main):005:0> a=0 ; Dir.open("/SRPMS").each { print "\r#{a+=1}" } 1117# Globbing from the shell: [gc@obiwan ~] ls -d /mnt/* | wc -l 5 [gc@obiwan ~] ls -d /SRPMS/* | wc -l 1115 Globbing from the glibc: [gc@obiwan ~/tmp] cat > t.c #include #include int main() { glob_t g; glob("/SRPMS/*", 0, NULL, &g); printf("matches: #%d\n", g.gl_pathc); } [gc@obiwan ~/tmp] gcc t.c [gc@obiwan ~/tmp] ./a.out matches: #1115 [gc@obiwan ~] ruby -v ruby 1.6.3 (2001-03-22) [i586-linux-gnu] Best, -- Guillaume Cottenceau - http://mandrakesoft.com/~gc/