Feature #5994
closedDir.glob without wildcards returns pattern, not filename
Description
This is Windows specific, I guess, as filename case doesn't matter there.
Ruby version is not specific to 1.9.3p0 (ruby 1.8.7p334 gives the same).
The script below produces results that seem inconsistent.
Using special characters (wildcards) in the glob pattern returns the
actual filename on disk but a plain pattern (no wildcards) returns the
pattern itself. This means I have to use another method for producing
a file with the same name or else override the users case-style
preference (which is not my intention).
daz
#======================
puts 'ruby %sp%d (%s) [%s]' % [RUBY_VERSION, RUBY_PATCHLEVEL, RUBY_RELEASE_DATE, RUBY_PLATFORM]
# ruby 1.9.3p0 (2011-10-30) [i386-mingw32]
Dir.chdir ENV['TEMP']
TMPDIR = Time.now.strftime('%Y%m%d_%H%M%S_delete')
Dir.mkdir(TMPDIR)
Dir.chdir(TMPDIR)
TMPFN = 'Foo'
File.open(TMPFN, 'w') {}
#----------------------------------------------
p Dir.glob('*') #=> ["Foo"] ok
p Dir.glob('f?O') #=> ["Foo"] ok
# But a glob without special characters returns
# the glob pattern instead of the filename
p Dir.glob('foO') #=> ["foO"] not wanted
p Dir['foO'] #=> ["foO"] same as above
p Dir.glob('foO', File::FNM_CASEFOLD)
# casefold ignored, as docs say
#----------------------------------------------
File.delete(TMPFN)
Dir.delete(File.join('..', TMPDIR))
#+++++
# Same incorrect results from:
# ruby 1.8.7p334 (2011-02-18) [i386-mingw32]
Added by nobu (Nobuyoshi Nakada) about 11 years ago
Added by naruse (Yui NARUSE) about 11 years ago
Revert "dir.c: glob cases on case-insensitive system"
This reverts commit r44796.
* dir.c (glob_helper): return the filename with actual cases on
the filesystem if it is case-insensitive. [ruby-core:42469]
[Feature #5994]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Added by nobu (Nobuyoshi Nakada) about 11 years ago
dir.c: glob cases on case-insensitive system
- dir.c (glob_make_pattern): all alphabets are magic characters on
case-insensitive filesystems. [ruby-core:42469] [Feature #5994]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Added by nobu (Nobuyoshi Nakada) about 11 years ago
dir.c: glob cases on case-insensitive system
- dir.c (glob_helper): return the filename with actual cases on
the filesystem if it is case-insensitive. [ruby-core:42469]
[Feature #5994]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
dir.c: glob cases on case-insensitive system
the filesystem if it is case-insensitive. [ruby-core:42469]
[Feature #5994]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e