Is this a ruby bug?

J

J. D.

In the following code, the line marked #bad# only finds '.' and '..'
directories. But the line marked #good# finds all the subdirectories.

I tested this in the same directory, passing the same argument (even so
far as using the UP arrow key to avoid typo differences).

Is this a bug in Ruby 1.8.2 snapshot? Should the two lines produce the
same results?

8<--------

#ruby

def dirloop(rootdir)


#bad# Dir.foreach(rootdir){|dir|
#good# Dir[rootdir + "/**/*"].each{|dir|

if(FileTest.directory?(dir)) then
puts "found directory #{dir}";
end
}
end

rootDir = ARGV[0];
puts "starting at root directory #{rootDir}";
dirloop(rootDir);
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: Is this a ruby bug?"

|In the following code, the line marked #bad# only finds '.' and '..'
|directories. But the line marked #good# finds all the subdirectories.
|
|I tested this in the same directory, passing the same argument (even so
|far as using the UP arrow key to avoid typo differences).
|
|Is this a bug in Ruby 1.8.2 snapshot? Should the two lines produce the
|same results?

I fixed several bugs in file globing. Try CVS ruby_1_8 branch or
tomorrow's stable snapshot.

matz.
 
J

J. D.

Yukihiro said:
Hi,

In message "Re: Is this a ruby bug?"

|In the following code, the line marked #bad# only finds '.' and '..'
|directories. But the line marked #good# finds all the subdirectories.
|
|I tested this in the same directory, passing the same argument (even so
|far as using the UP arrow key to avoid typo differences).
|
|Is this a bug in Ruby 1.8.2 snapshot? Should the two lines produce the
|same results?

I fixed several bugs in file globing. Try CVS ruby_1_8 branch or
tomorrow's stable snapshot.

matz.

Thanks matz!

You are truly amazing.
 

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

No members online now.

Forum statistics

Threads
473,813
Messages
2,569,696
Members
45,480
Latest member
CrazyMember

Latest Threads

Top