|
# vim: ts=2 sw=2 et ai
|
|
#
|
|
# Version:
|
|
# ruby 2.6.5p114 (2019-10-01 revision 67812) [x64-mingw32]
|
|
#
|
|
# Summary: Dir globbing case sensitivity inconsistencies
|
|
#
|
|
# Details: directory globbing case sensitivity is os-dependent
|
|
# (https://ruby-doc.org/core-2.6.5/Dir.html, glob,
|
|
# "Case sensitivity depends on your system");
|
|
# On Windows 10, directory globbing is case insensitive,
|
|
# and may return glob matches that do
|
|
# not match the case of the query.
|
|
# Unfortunately, File.fnmatch seems to be case sensitive,
|
|
# so this is not a workaround.
|
|
#
|
|
# Expected:
|
|
# If Dir.pwd => 'C:/users/dave/Documents' (lower case for users)
|
|
# then Dir[Dir.pwd+'/*'] => ['C:/users/dave/Documents/...',...]
|
|
# (lower case for users), not [C:/Users/dave/Documents/...',...]
|
|
#
|
|
#
|
|
# Impact:
|
|
# Rails 6.0 Activeview implementation has an assumption that
|
|
# case is sensitive.
|
|
#
|
|
# Demonstration:
|
|
# The below script yields the following output. Note that
|
|
# Dir.pwd yields C:/users..., where a Dir glob of files in
|
|
# that directory is prefixed with C:/Users...
|
|
|
|
cd = Dir.pwd
|
|
puts "Dir.pwd => '#{cd}'"
|
|
cds = cd + '/*'
|
|
fm0 = Dir[cds][0]
|
|
puts "Dir['#{cds}'][0] => '#{fm0}'"
|
|
puts "Does the first matching entry match the base path of the query?"
|
|
m = fm0.start_with? cd
|
|
p m
|
|
# How about File.fnmatch?
|
|
m2 = File.fnmatch cds,fm0
|
|
puts "fnmatch: #{m2}"
|
|
|
|
#=> Dir.pwd => 'C:/users/dave/Documents/rails'
|
|
#=> Dir['C:/users/dave/Documents/rails/*'][0] => 'C:/Users/dave/Documents/rails/blog'
|
|
#=> Does the first matching entry match the base path of the query?
|
|
#=> false
|
|
#=> fnmatch: false
|