Found a Find.find() bug?

R

robertlaferla

I was trying out Find.find() today and found that if you pass it a directory without a trailing slash, it doesn't traverse the directory. This seems like a bug to me. Is it? If so, how do I report it?

e.g.

require 'find'
Find.find("/tmp/") do |path|
puts path
end

vs.

require 'find'
Find.find("/tmp/") do |path|
puts path
end
 
A

ara.t.howard

I was trying out Find.find() today and found that if you pass it a
directory without a trailing slash, it doesn't traverse the directory.
This
seems like a bug to me. Is it? If so, how do I report it?

e.g.

require 'find'
Find.find("/tmp/") do |path|
puts path
end

vs.

require 'find'
Find.find("/tmp/") do |path|
puts path
end
Unless I'm missing something, your two examples are exactly
the same.

I am running ruby 1.8.5 (2006-12-25 patchlevel 12) [i386-freebsd6]

And I tried a quick test
of: Find.find("/tmp")
vs: Find.find("/tmp/")

And I seemed to get the same result from both. In my case, both
tests found 131 directories and 27 "other things" (ie, "not directories").

What platform are you running ruby on?
Which version of ruby are you running?

i __think__ this could happen if /tmp were a soft link... ??

-a
 
P

Philip Hallstrom

I was trying out Find.find() today and found that if you pass it a
directory without a trailing slash, it doesn't traverse the directory.
This
seems like a bug to me. Is it? If so, how do I report it?

e.g.

require 'find'
Find.find("/tmp/") do |path|
puts path
end

vs.

require 'find'
Find.find("/tmp/") do |path|
puts path
end
Unless I'm missing something, your two examples are exactly
the same.

I am running ruby 1.8.5 (2006-12-25 patchlevel 12) [i386-freebsd6]

And I tried a quick test
of: Find.find("/tmp")
vs: Find.find("/tmp/")

And I seemed to get the same result from both. In my case, both
tests found 131 directories and 27 "other things" (ie, "not directories").

What platform are you running ruby on?
Which version of ruby are you running?

i __think__ this could happen if /tmp were a soft link... ??

It can using normal OS commands so I'd imagine the same is true with
Ruby...
 
B

Ben Bleything

i __think__ this could happen if /tmp were a soft link... ??

Yup! This bites me all the time on osx:

folio ~/projects > ls /tmp
/tmp@

folio ~/projects > ls -l /tmp
lrwxr-xr-x 1 root admin 11 Dec 12 15:34 /tmp@ -> private/tmp

folio ~/projects > ls /tmp/
1f7ead7c295b42d3030a746438a8d222 2285/ ...

Ben
 
A

ara.t.howard

Yup! This bites me all the time on osx:

folio ~/projects > ls /tmp
/tmp@

folio ~/projects > ls -l /tmp
lrwxr-xr-x 1 root admin 11 Dec 12 15:34 /tmp@ -> private/tmp

folio ~/projects > ls /tmp/
1f7ead7c295b42d3030a746438a8d222 2285/ ...

Ben

moral:

path = File.expand_path path

;-)

-a
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top