Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path/filepath: Glob is case-sensitive on Windows #5441

Open
gopherbot opened this issue May 10, 2013 · 26 comments
Open

path/filepath: Glob is case-sensitive on Windows #5441

gopherbot opened this issue May 10, 2013 · 26 comments
Labels
NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. OS-Windows
Milestone

Comments

@gopherbot
Copy link

by me@conradz.com:

What steps will reproduce the problem?

Copy the program at http://play.golang.org/p/9G14FfcKES into a .go file and run in a
directory that has write permissions (it will create the test.txt file).

What is the expected output?

Files found with *.txt: [test.txt]
Files found with *.TXT: [test.txt]

What do you see instead?

Files found with *.txt: [test.txt]
Files found with *.TXT: []

Which compiler are you using (5g, 6g, 8g, gccgo)?
8g

Which operating system are you using?
Windows 8 64-bit

Which version are you using?  (run 'go version')
go version go1.1rc3 windows/386


File paths on Windows are normally case-insensitive, but the filepath.Glob is currently
case-sensitive on Windows. I would expect it to be case-sensitive if the OS has
case-sensitive paths, and be case-insensitive if the OS has case-insensitive paths.
@rsc
Copy link
Contributor

rsc commented May 24, 2013

Comment 1:

fwiw, case sensitivity is a function of the mounted file system, not the OS.

@gopherbot
Copy link
Author

Comment 2 by me@conradz.com:

See http://msdn.microsoft.com/en-us/library/ee681827%28v=vs.85%29.aspx for a summary of
the different file systems on Windows, and which are case-sensitive. Also note that NTFS
can be case-sensitive or insentive, depending on the global OS settings. UDF is the only
common file system on Windows that is always case-sensitive. Making Windows
case-insensitive would take care of 99.9% of cases, but there would be a few edge cases.

@robpike
Copy link
Contributor

robpike commented May 28, 2013

Comment 3:

Labels changed: added priority-later, removed priority-triage.

Status changed to Thinking.

@alexbrainman
Copy link
Member

Comment 5:

I think Russ's argument does not fly here. Whe have an issue here where Go program
cannot find file that is there. It is irrelevent what file system capabilities are,
since win32 api (we use it to access os services) makes them all look case insensitive.
From http://support.microsoft.com/kb/100625:
"... The difference in behavior noted here applies only when an application needs to
locate an existing file. POSIX takes advantage of the full case sensitive mode, while
MS-DOS, WOW, and Win32 subsystems use the case insensitive mode. ..."
I am yet to see a windows program that assumes case sensitive mode.
Here is cmd.exe to demonstrate:
C:\tmp\aaa>dir
 Volume in drive C has no label.
 Volume Serial Number is F582-OP83
 Directory of C:\tmp\aaa
29/05/2013  09:16 AM    <DIR>          .
29/05/2013  09:16 AM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  115,812,872,192 bytes free
C:\tmp\aaa>echo hello > a.txt
C:\tmp\aaa>dir
 Volume in drive C has no label.
 Volume Serial Number is F582-OP83
 Directory of C:\tmp\aaa
29/05/2013  09:16 AM    <DIR>          .
29/05/2013  09:16 AM    <DIR>          ..
29/05/2013  09:16 AM                 8 a.txt
               1 File(s)              8 bytes
               2 Dir(s)  115,812,872,192 bytes free
C:\tmp\aaa>echo hello2 > A.TXT
C:\tmp\aaa>dir
 Volume in drive C has no label.
 Volume Serial Number is F582-OP83
 Directory of C:\tmp\aaa
29/05/2013  09:16 AM    <DIR>          .
29/05/2013  09:16 AM    <DIR>          ..
29/05/2013  09:17 AM                 9 a.txt
               1 File(s)              9 bytes
               2 Dir(s)  115,812,872,192 bytes free
C:\tmp\aaa>dir *.txt
 Volume in drive C has no label.
 Volume Serial Number is F582-OP83
 Directory of C:\tmp\aaa
29/05/2013  09:17 AM                 9 a.txt
               1 File(s)              9 bytes
               0 Dir(s)  115,812,872,192 bytes free
C:\tmp\aaa>dir *.TXT
 Volume in drive C has no label.
 Volume Serial Number is F582-OP83
 Directory of C:\tmp\aaa
29/05/2013  09:17 AM                 9 a.txt
               1 File(s)              9 bytes
               0 Dir(s)  115,812,872,192 bytes free
C:\tmp\aaa>dir A.TXT
 Volume in drive C has no label.
 Volume Serial Number is F582-OP83
 Directory of C:\tmp\aaa
29/05/2013  09:17 AM                 9 a.txt
               1 File(s)              9 bytes
               0 Dir(s)  115,812,872,192 bytes free
C:\tmp\aaa>dir a.txt
 Volume in drive C has no label.
 Volume Serial Number is F582-OP83
 Directory of C:\tmp\aaa
29/05/2013  09:17 AM                 9 a.txt
               1 File(s)              9 bytes
               0 Dir(s)  115,812,872,192 bytes free
C:\tmp\aaa>type a.txt
hello2
C:\tmp\aaa>type A.TXT
hello2
C:\tmp\aaa>type A.txT
hello2
C:\tmp\aaa>del a.txt
C:\tmp\aaa>dir
 Volume in drive C has no label.
 Volume Serial Number is F483-CD2E
 Directory of C:\tmp\aaa
29/05/2013  09:24 AM    <DIR>          .
29/05/2013  09:24 AM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  115,812,839,424 bytes free
C:\tmp\aaa>echo hello > A.TXT
C:\tmp\aaa>dir
 Volume in drive C has no label.
 Volume Serial Number is F483-CD2E
 Directory of C:\tmp\aaa
29/05/2013  09:24 AM    <DIR>          .
29/05/2013  09:24 AM    <DIR>          ..
29/05/2013  09:24 AM                 8 A.TXT
               1 File(s)              8 bytes
               2 Dir(s)  115,812,839,424 bytes free
C:\tmp\aaa>
IMO our current implementation behaives differently, and should be changed.
Alex

@alexbrainman
Copy link
Member

Comment 6:

me@conradz.com,
Can you see if https://golang.org/cl/9666048 fixes your problem, please? Thank
you.
Alex

@gopherbot
Copy link
Author

Comment 7 by me@conradz.com:

Yes, the above change does work. Globs are case-insensitive on Windows with the change
applied.

@alexbrainman
Copy link
Member

Comment 8:

me@conradz.com,
Thank you for testing. Leaving for rsc and r to decide what to do.
Alex

@alexbrainman
Copy link
Member

Comment 9:

r / rsc, can you, please, decide one way or the other, so we can close this. Thank you.
Alex

@adg
Copy link
Contributor

adg commented Jun 21, 2013

Comment 10:

I'm not r/rsc, but I think the proposed change is the right direction.

@robpike
Copy link
Contributor

robpike commented Jun 21, 2013

Comment 11:

I put some comments on https://golang.org/cl/9666048/

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 12:

Labels changed: added go1.2maybe.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 13:

Labels changed: added feature.

@rsc
Copy link
Contributor

rsc commented Sep 9, 2013

Comment 14:

Too late.

Labels changed: added go1.3maybe, removed go1.2maybe.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 15:

Labels changed: removed feature.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 16:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 17:

Labels changed: added repo-main.

@alexbrainman
Copy link
Member

My proposed fix https://codereview.appspot.com/9666048 and all comments are lost now. The URL returns "No issue exists with that id (9666048)". As far as I remember my proposal was rejected and @rsc was going to send his own fix. I am not clear of rejection reason. As far as I recall I was not clear back then either. Perhaps it was to do with not wanting to import "unicode" package here.

Alex

@robpike
Copy link
Contributor

robpike commented May 18, 2015

Sorry about that. The transition to github was bumpy and lossy.

@mwhudson
Copy link
Contributor

You can find at least some of the info by searching for "9666048" on golang-dev and golang-codereviews.

@minux
Copy link
Member

minux commented May 18, 2015 via email

@alexbrainman
Copy link
Member

Thank you for history search pointers. But, more importantly, I think we need to remove "Thinking" label off this issue. We need to decide what to do here. We might decide it is working as intended, then we should document that Glob search is case-sensitive. Or we might decide to change the code.

Alex

@phoenix147
Copy link

I just ran into this problem and wanted to ask if there is a decision for this?

@bradfitz bradfitz added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jan 21, 2018
@bradfitz bradfitz modified the milestones: Unplanned, Go1.11 Jan 21, 2018
@ianlancetaylor ianlancetaylor modified the milestones: Go1.11, Go1.12 Jun 27, 2018
@rsc
Copy link
Contributor

rsc commented Nov 28, 2018

It seems too late to try to change this. It would require a lot of checking of whether a particular file system is case-sensitive. You'd have to check in every directory where you were evaluating wildcards, and I'm not even sure how to check.

Do other languages attempt to do this? I know Python, Node, etc have globbing libraries.

@andybons andybons added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Dec 5, 2018
@andybons andybons modified the milestones: Go1.12, Go1.13 Dec 5, 2018
@freb
Copy link

freb commented Dec 12, 2018

In the Python pathlib module, there are only two different flavours used by glob and the other functions: Windows and Posix

Each has their own implementation of casefold, which prepares path strings for comparison. Windows uses lower case, and Posix uses the original case.

It doesn't appear to take file system case sensitivity into account.

@gopherbot
Copy link
Author

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@dominikh dominikh reopened this Jan 5, 2019
@andybons andybons removed this from the Go1.13 milestone Jul 8, 2019
@ALTree ALTree removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jan 7, 2020
@neclepsio
Copy link

Is there any workaround for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. OS-Windows
Projects
None yet
Development

No branches or pull requests