r/ProgrammerTIL • u/cdrini • Oct 09 '18
Other Language [Other] TIL filenames are case INSENSITIVE in Windows
I've been using Windows for way too long and never noticed this before... WHY?!?!
$ ls
a.txt b.txt
$ mv b.txt A.txt
$ ls
A.txt
71
Upvotes
18
u/[deleted] Oct 09 '18
This makes me uncomfortable. You cannot do this in a windows command-prompt or powershell, correct? You're using a bash shell on Windows?
I'm kind of surprised at this behavior. The shell allowed you to move a file even though the destination already exists, and it overwrote the destination file without even a warning...
55
u/notQuiteApex Oct 09 '18
it was likely a decision made to make computers more accessible to not-so-tech-savvy people. to be honest, its kind of better since you really shouldnt have files that have names only differing by their character case. i wont deny that it is odd to be the only operating system that does this however.
27
u/redditsoaddicting Oct 09 '18
FYI, the actual filesystem (NTFS) is case-sensitive. The case-insensitivity comes from the layers on top of NTFS.
5
u/13steinj Oct 09 '18 edited Oct 09 '18
Actually, there's five types
E: To clarify-- NTFS is indeed "case sensitive", but Windows (the major use of NTFS) by default creates, opens, and deletes files in a "case insensitive, case preserving" manner.
You can force windows to open them in a "case sensitive" manner by passing in a "follow posix semantics" flag (0x0100000) to the relevant apis.
9
u/HereticKnight Oct 09 '18 edited Oct 09 '18
Same with OS X. Apple’s new file system, APFS, supports case sensitive volumes but it’s disabled by default. If you need a case sensitive file system, you can thin provision one alongside your primary without rebooting or anything; it’s fucking awesome.
Also, case sensitivity breaks some applications, notably Adobe’s shit.
My (least) favorite example of non-obvious breakage was a GoLang logging package which I won’t dignify by naming. The maintainer changed the GitHub org name to a different case. Git is case sensitive. It horribly broke everything downstream, including well-known stuff like Docker. My team mates who develop on Linux kept pushing shit that broke my local repos for months.
Edit: APFS, not AFS
4
u/themoosemind Oct 09 '18
Imagine the fun I had when I created a git repo with two files that differed only by case... Didn't discover it until two years later a Windows user complained (it already had about 50 stars and a couple of forks). Debugging took a while.
4
u/sim642 Oct 09 '18
That is the very worst. Recently had a friend who renamed a directory from uppercase to lowercase in a project and tried to commit the changes with git. It broke absolutely everything. PyCharm got confused by git getting confused and there were paths staged that simply couldn't be manipulated because something saw them as different but something else saw them as the same.
Did the same rename on my Linux machine, zero issues.
1
u/ferrx Oct 09 '18
Ran into this doing Angular development on windows. An import on a file that worked fine in Windows, threw errors in our CentOS-based test environment.
1
u/WestonP Oct 09 '18
Yup, this has been the case ever since the DOS days. It's much more user friendly than the possibility of MyFile.txt and MYFILE.txt coexisting. I'm kind of surprised that this is apparently not common knowledge among developers.
5
u/karnthis Oct 09 '18
Just wait til you add a Linux drive to your windows file explorer and try to view directories with the same file names and different capitalization.
2
u/TJourney Oct 09 '18
I wonder if it is because of backward compatibility to 8+3 filenames, and to "simplify" file extension cases in Windows.
Super weird.
1
u/[deleted] Oct 09 '18
This has fucked me before when doing stuff with git bash
1
u/Makusu2 Oct 09 '18
Weird... So what would happen if you plugged a USB drive with a.txt and A.txt into a Windows device, then tried to access those files?
For purposes of the argument, let's say thing drive is using FAT32
1
u/m3g3n1u5 Oct 09 '18
If you move a folder A to another B that contains one with the same name A: Windows will merge both A Mac will replace.. no questions asked.
Can someone confirm?
1
u/Qkb Oct 19 '18
I once had a git repo that had the same name but with differents caps. This caused so much trouble for me when I jumped from my linux box to a windows box.
-1
u/[deleted] Oct 09 '18
NTFS has too many restrictions, in my opinion.
0
u/elperroborrachotoo Oct 09 '18
STAIL file names are case sensitive on some OS, and tools originating from those OS'es often fail to handle case insensitivity correctly.
0
u/[deleted] Oct 09 '18
[deleted] — view deleted comment