From: Clifford Heath Date: 2003-05-14T10:59:18+09:00 Subject: Bug in backslash-escapes in Dir.glob I mentioned this problem before, now I have two test programs that show it. One's in Perl, one's in Ruby. The Perl one behaves correctly, the Ruby one not. First the Perl one, globtest.pl: #! /usr/bin/perl -w use strict; my $testdir = shift @ARGV; mkdir($testdir); open(FILE, ">$testdir/file 1"); close(FILE); open(FILE, ">$testdir/file 2"); close(FILE); $testdir =~ s/ /?/g; my @files = glob("$testdir/*\\ *"); for my $file (@files) { print "$file\n"; } $ perl globtest.pl 'glob test' glob test/file 1 glob test/file 2 $ So far so good. Now the ruby version, globtest.rb: #! /usr/bin/ruby testdir = ARGV.shift Dir.mkdir(testdir) (1..2).each { |i| File.new("#{testdir}/file #{i}", "w").close } p Dir.glob("#{testdir.gsub(/ /, '?')}/*\ *") $ ruby globtest.rb 'glob test' ["glob test/file 1", "glob test/file 2", "globtest.rb", "glob test"] $ The problem is that no amount of backslash-escaping of the space in the glob pattern prevents the closing "*" from matching everything. Clifford Heath.