German makes bash act strange

When LANG is set to de_DE.UTF-8, the globbing in bash is case-insensitive, which is very confusing.

Example:

First we look at the LANG variable.

kumbach@dualprinzip ~ % echo $LANG
de_DE.UTF-8

Now we start bash (I normally use zsh) and enter the directory /tmp/test with two files, FOO and foo.

kumbach@dualprinzip ~ % bash
kumbach@dualprinzip: ~ $ cd /tmp/test
kumbach@dualprinzip: /tmp/test $ ls
foo  FOO

Everything looks pretty normal so far, no we try ls with globbing:

kumbach@dualprinzip: /tmp/test $ ls [a-z]*
foo  FOO

WHAT? Why is it matching FOO?

kumbach@dualprinzip: /tmp/test $ exit

Now we try it with LANG=C, where bash is behaving as expected.

kumbach@dualprinzip ~ % LANG=C bash
kumbach@dualprinzip: ~ $ cd /tmp/test
kumbach@dualprinzip: /tmp/test $ ls [a-z]*
foo
kumbach@dualprinzip: /tmp/test $

btw.: zsh does not have this strange behaviour.

Conclusion

Be careful when using globbing in scripts, even if you set LANG=C inside your script, the interpreter itself might run in another environment, so globbing will still be German.

This does not happen if LANG is set to en_US.UTF-8, so it seems not to be a UTF-8 issue, just a German problem (and maybe other languages).