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?

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

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.

Yukihiro Matsumoto wrote:

Hi,

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

···

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