Trailing slash issue in Find.find

require “find"
Find.find(”/usr/bin/") { |file| puts file }

[…]
/usr/bin//rmdir
/usr/bin//rm
/usr/bin//mv
/usr/bin//mknod
/usr/bin//mkfifo
/usr/bin//mkdir
/usr/bin//ls
/usr/bin//ln
/usr/bin//install
/usr/bin//du
/usr/bin//dircolors
/usr/bin//dir
/usr/bin//df
/usr/bin//dd
/usr/bin//cp
[…]

I ran into this while doing string compares between filenames obtained
from File.find and filenames obtained elsewhere. Needless to say they
didn’t compare very well :slight_smile:

FWIW, GNU’s find, BSD’s find, and perl’s find all produce the same output
for “/usr/bin” and “/usr/bin/”.

-Jeff

~$ ruby -v
ruby 1.8.0 (2003-08-04) [i686-linux]
~$ ruby -rfind -e ‘Find.find(“/usr/bin/”) { |f| puts f }’ 2>&1 | head -n 10
/usr/bin/
/usr/bin/db_load
/usr/bin/db_dump
/usr/bin/xscreensaver-demo
/usr/bin/prtwash
/usr/bin/ssh-keygen
/usr/bin/prt-get
/usr/bin/bunzip2
/usr/bin/lwp-rget
/usr/bin/afmtodit
~$

So it appears to be fixed in 1.8

Jason Creighton

···

On 23 Aug 2003 16:30:02 -0700 quixoticsycophant@yahoo.com (Jeff Mitchell) wrote:

require “find”
Find.find(“/usr/bin/”) { |file| puts file }

[…]
/usr/bin//rmdir
/usr/bin//rm
/usr/bin//mv
/usr/bin//mknod
/usr/bin//mkfifo
/usr/bin//mkdir
/usr/bin//ls
/usr/bin//ln
/usr/bin//install
/usr/bin//du
/usr/bin//dircolors
/usr/bin//dir
/usr/bin//df
/usr/bin//dd
/usr/bin//cp
[…]

I ran into this while doing string compares between filenames obtained
from File.find and filenames obtained elsewhere. Needless to say they
didn’t compare very well :slight_smile:

FWIW, GNU’s find, BSD’s find, and perl’s find all produce the same output
for “/usr/bin” and “/usr/bin/”.