Project

General

Profile

Actions

Bug #16391

closed

Dir.pwd, Dir[] pathname case inconsistency

Added by dbuck (Dave Buck) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.5p114 (2019-10-01 revision 67812) [x64-mingw32]
[ruby-core:96062]

Description

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/...',...] (upper case Users)

Impact:
Rails 6.0 Activeview implementation has an assumption that
case in pwd will match that in glob


Files

dlbdirbug.rb (1.65 KB) dlbdirbug.rb Demonstration script dbuck (Dave Buck), 12/02/2019 06:32 PM

Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Description updated (diff)

Dir.pwd returns 'C:/Users/...', not 'C:/users/...' for me.

Unfortunately, File.fnmatch seems to be case sensitive,
so this is not a workaround.

File::Constants has two constants for File.fnmatch

  • FNM_CASEFOLD:
    Makes File.fnmatch patterns case insensitive (but not Dir.glob patterns).

  • FNM_SYSCASE:
    System default case insensitiveness, equals to FNM_CASEFOLD or 0.

Actions #2

Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Status changed from Open to Closed

Applied in changeset git|fb11e6089dbe9d995510977def038a21882bcffe.


[DOC] Added File::FNM_SYSCASE example [Bug #16391] [ci skip]

Actions

Also available in: Atom PDF

Like0
Like0Like0