Dir.glob problem

D

Dmitry V. Sabanin

Hi,

I have a strange problem with Dir.glob and directory symlinks on linux.
There's a directory:
$ ls -l /tmp/test
drwxr-xr-x 2 sdmitry sdmitry 80 Sep 13 10:40 test1
drwxr-xr-x 2 sdmitry sdmitry 80 Sep 13 10:40 test2
lrwxrwxrwx 1 sdmitry sdmitry 8 Sep 13 10:40 test3 -> ../test3
Each sub-directory has files with .file extension. Here's the problem:
$ ruby -e "p Dir.glob('**/*.file')"
["test1/test.file", "test2/test2.file"]
Why there's no test3 files in the result? And what simple workaround can I use
to get:
["test1/test.file", "test2/test2.file", "test3/test3.file"]

Thanks in advance,
 
N

nobu.nokada

Hi,

At Mon, 13 Sep 2004 11:53:11 +0900,
Dmitry V. Sabanin wrote in [ruby-talk:112357]:
I have a strange problem with Dir.glob and directory symlinks on linux.
There's a directory:
$ ls -l /tmp/test
drwxr-xr-x 2 sdmitry sdmitry 80 Sep 13 10:40 test1
drwxr-xr-x 2 sdmitry sdmitry 80 Sep 13 10:40 test2
lrwxrwxrwx 1 sdmitry sdmitry 8 Sep 13 10:40 test3 -> ../test3
Each sub-directory has files with .file extension. Here's the problem:
$ ruby -e "p Dir.glob('**/*.file')"
["test1/test.file", "test2/test2.file"]
Why there's no test3 files in the result? And what simple workaround can I use
to get:
["test1/test.file", "test2/test2.file", "test3/test3.file"]

"**" doesn't traverse symbolic links, or it can cause an
infinite loop.

$ ruby -e "p Dir.glob('*/**/*.file')"
["test1/test1.file", "test2/test2.file", "test3/test3.file"]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,159
Messages
2,570,883
Members
47,415
Latest member
SharonCran

Latest Threads

Top