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 · 24 comments

Comments

Projects
None yet
@gopherbot

gopherbot commented May 10, 2013

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

This comment has been minimized.

Contributor

rsc commented May 24, 2013

Comment 1:

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

This comment has been minimized.

gopherbot commented May 24, 2013

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

This comment has been minimized.

Contributor

robpike commented May 28, 2013

Comment 3:

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

Status changed to Thinking.

@alexbrainman

This comment has been minimized.

Member

alexbrainman commented May 28, 2013

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

This comment has been minimized.

Member

alexbrainman commented May 29, 2013

Comment 6:

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

This comment has been minimized.

gopherbot commented May 29, 2013

Comment 7 by me@conradz.com:

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

This comment has been minimized.

Member

alexbrainman commented May 29, 2013

Comment 8:

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

This comment has been minimized.

Member

alexbrainman commented Jun 20, 2013

Comment 9:

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

This comment has been minimized.

Contributor

adg commented Jun 21, 2013

Comment 10:

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

This comment has been minimized.

Contributor

robpike commented Jun 21, 2013

Comment 11:

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

This comment has been minimized.

Contributor

rsc commented Jul 30, 2013

Comment 12:

Labels changed: added go1.2maybe.

@rsc

This comment has been minimized.

Contributor

rsc commented Jul 30, 2013

Comment 13:

Labels changed: added feature.

@rsc

This comment has been minimized.

Contributor

rsc commented Sep 9, 2013

Comment 14:

Too late.

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

@rsc

This comment has been minimized.

Contributor

rsc commented Nov 27, 2013

Comment 15:

Labels changed: removed feature.

@rsc

This comment has been minimized.

Contributor

rsc commented Dec 4, 2013

Comment 16:

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

@rsc

This comment has been minimized.

Contributor

rsc commented Dec 4, 2013

Comment 17:

Labels changed: added repo-main.

@alexbrainman

This comment has been minimized.

Member

alexbrainman commented May 18, 2015

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

This comment has been minimized.

Contributor

robpike commented May 18, 2015

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

@mwhudson

This comment has been minimized.

Contributor

mwhudson commented May 18, 2015

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

@minux

This comment has been minimized.

@alexbrainman

This comment has been minimized.

Member

alexbrainman commented May 19, 2015

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

This comment has been minimized.

phoenix147 commented Jan 20, 2018

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

@rsc

This comment has been minimized.

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 modified the milestones: Go1.12, Go1.13 Dec 5, 2018

@freb

This comment has been minimized.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment