Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Are bash commands on OSX case insensitive? I type "which TR" and it shows /usr/bin/TR, though there is no such binary there. Same thing for other binaries, when capitalized. Or is Terminal.app maybe doing this translation? How do I turn this off?

share|improve this question
    
Out of curiosity, why would you want to turn this off? –  Sören Kuklau Aug 17 '11 at 16:04
    
This is a spectacular question. Bash has a nocaseglob option to control whether cases match in ranges, but this little bit of trickery is deeper than the normal locale and completion-ignore-case / nocaseglob –  bmike Aug 17 '11 at 16:11
2  
The reason I wanted to turn it off is silly, really. I'm used to case sensitivity when working at the shell. I am just worried this feature will trip me up. Example, I write a bash script, mistype 'lS'; the script will run fine on OSX. I move it to my cenTOS box, and it breaks. Granted, this would be easy to detect and fix, but could avoid the scenario entirely if I could keep the scripts working the same way between the two systems. I discovered this by accident, and it hasn't been a nuisance thus far, so I probably will not go through the exercise changing filesystems just for this. –  verboze Aug 19 '11 at 1:30
4  
The reason you would want to turn this off is that case insensitivity causes problems for some apps, like SVN. Case insensitive globbing could be useful, but SVN gets very very confused if you create a file called "Foo", then somehow the repository creates a reference to "foo". –  user41214 Feb 5 '13 at 19:01

3 Answers 3

up vote 46 down vote accepted

This is actually a feature of the filesystem of your disk, not bash or Terminal.app.

HFS+ (the Mac filesystem) is usually configured to be case insensitive but case preserving. This means that the file system will consider foo and FoO to be the same, but when you create a new file it will remember which letters where capitalized and which were not.

When you format a disk with HFS+ you can chose whether the file system should case sensitive or not. If you chose to format with UFS (Unix FileSystem) it is always case sensitive, AFAIK.

To check whether a disk is case sensitive, run:

 diskutil info <device>

For example:

 diskutil info disk0s2

Look for the Name: line. If it reads something like Mac OS Extended (Case-sensitive, Journaled) it means that it is case-sensitive. If it just reads Mac OS Extended (without the Case-sensitive) then it is only case preserving but not case sensitive.

share|improve this answer
    
HFS+ really is a bit of an oddity, having the ability to both recognise and ignore case at the same time. Your case preserving note was missing from my answer, and is important for a Unix based OS which would normally be expected to be case sensitive where Foo and FOO are 2 different files. I suspect the behaviour came about between Mac OS 9 HFS and Mac OS X HFS+ and the requirement to be understood by both classic and new apps etc. –  stuffe Aug 17 '11 at 16:49
6  
Outside of Unix, the case preserving nature isn't so unusual. For example, NTFS is the similar: not case sensitive by default, but you can format it so it is. I also think that the case insensitive is default came via Mac OS 9, but the fact that a lot of Mac and Windows developers are lazy in this respect and don't care about correct casing makes it almost impossible to switch to case sensitive as default, it breaks lots of apps. Coming from Unix, I found it very strange at first as well. –  DarkDust Aug 17 '11 at 16:57
    
I haven't gone back and looked, but I'm pretty sure Mac OS has used case-preserving (but not case-sensitive) filesystems since the original 1984 Mac (which used MFS -- Macintosh File System -- to format its 400k floppy disks) –  Gordon Davisson Aug 17 '11 at 17:03
1  
I have to admit I never used Classic Mac OS, so was guessing. Either way, this is the answer, and DarkDust put it better than me so this one should be accepted I think. –  stuffe Aug 17 '11 at 17:11
6  
Every version of Mac OS has been case-insensitive-but-preserving, for usability reasons. While UNIX favours precision (byte-by-byte comparisons of filenames), it can be a usability nightmare for end users who accidentally save 'Resume' and 'REsume' and then get confused when they open the wrong version and all their changes are gone. –  Dan Udey Aug 17 '11 at 17:30

Take a look at your filesystem, as there are both case sensitive and case insensitive variations on HFS. The default is case insensitive, in which case it's not so much a case of BASH, but the underlying filesystem. You can test this by formatting a spare USB stick with the case sensitive option, and copying files over ato repeat your test, etc.

share|improve this answer

I managed to fix this with one line by following this:

http://blog.nickburwell.com/blog/2008/11/mac-os-x-terminal-case-insensitive-auto

Just be sure not to put the '>' at the beginning!

share|improve this answer
1  
Welcome to the site. We appreciate the link and if you want to, click edit and summarize the steps as that helps people know what the answer might be - especially if the link goes down or changes. –  bmike Dec 31 '13 at 20:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.