Neil Conway <nconway / klamath.dyndns.org> wrote: > >On Sat, Feb 24, 2001 at 01:19:22PM +0900, David Alan Black wrote: [...] >Is this a bug? Dir.glob works fine for directories without >a space in their names, but it always returns an empty array >on directories with spaces, AFAICT. I've tried the latest CVS >snapshot and the problem still occurs. Is this a bug with >Ruby or am I just being stupid? ;-) It appears that Ruby is a little closer to standard glob semantics than documented in the Ruby book. Though not quite close enough for my liking. The problem is that the glob is somewhere splitting the argument list on a space. Ordinarily I would just tell you to escape it, but it seems that Ruby does not follow traditional escaping semantics. :-( FWIW here is my test: bash-2.01$ ls bash-2.01$ touch foo bash-2.01$ touch bar bash-2.01$ touch this\ that bash-2.01$ ls bar foo this that bash-2.01$ ruby -e 'puts Dir.glob("foo bar")' foo bar bash-2.01$ ruby -e 'puts Dir.glob("this*")' this that bash-2.01$ ruby -e 'puts Dir.glob("this that")' bash-2.01$ ruby -e 'puts Dir.glob("this\ that")' bash-2.01$ ruby -e 'puts Dir.glob("this\\ that")' bash-2.01$ ruby -e 'puts Dir.glob("this\\\\ that")' And if you handle this you may also get bitten on the fact that you are skipping files which start with a period. But try this to list all files in a directory: ruby -e 'puts Dir.new(".").find_all {|f| test(?f, f)}' Here find_all is a method mixed in from Enumerable, and test is a method in Kernel. Cheers, Ben _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com