[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Is this a ruby bug?

JD

11/11/2004 5:01:00 AM

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);
2 Answers

Yukihiro Matsumoto

11/11/2004 6:10:00 AM

0

Hi,

In message "Re: Is this a ruby bug?"
on Thu, 11 Nov 2004 14:03:29 +0900, "J. D." <jd@nospam.com> writes:

|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.


JD

11/12/2004 9:52:00 PM

0

Yukihiro Matsumoto wrote:
> Hi,
>
> In message "Re: Is this a ruby bug?"
> on Thu, 11 Nov 2004 14:03:29 +0900, "J. D." <jd@nospam.com> writes:
>
> |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.