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