Shell – shopt -s nocaseglob is not working on Ubuntu

filenamesshellwildcards

Case insensitive file name globbing is not working in bash on Ubuntu 11.04 64bit. The shell options specified in .bashrc are as follows:

shopt -s nocaseglob 
shopt -s nocasematch

shopt also shows that nocaseglob and nocasematch are on. But for a directory change or opening a file, it doesn't work in case insensitivity mode.

I wish to check whether any other option is needed to enable case insensitive filename globbing.

Best Answer

Are you really doing globbing, i.e. wildcard expansion? For example, suppose that you have a directory called Foobar. Then

cd foobar

doesn't do globbing, because there is no wildcard character. When you specify a file name exactly, it's up to the application to decide what to do with it, and since unix file names are case sensitive, the application will not open a file called Foobar if you tell it to open a file called foobar.

On the other hand,

cd foo*

will change to the Foobar directory (assuming there is no other match), if you've set the nocaseglob option.

You can make completion case-insensitive too. Put set completion-ignore-case on in ~/.inputrc, or

bind 'set completion-ignore-case on'

in ~/.bashrc. Then after entering cd foo and pressing Tab, the shell will complete Foobar.

Related Question