Description of problem: In a script, bash erroneously includes files that start with an uppercase letter in the glob [a-z]*. Version-Release number of selected component (if applicable): bash 2.05 release 8 How reproducible: Run this script: ----- 8< -------------------------------------- #!/bin/bash mkdir -p /var/tmp/globtest > /dev/null 2>&1 cd /var/tmp/globtest || exit 1 rm -f * touch capybara touch CAPYBARA touch hippo touch vole touch VOLE for LOWERCASE in [a-z]*; do echo $LOWERCASE should start with a lowercase letter. done ----- 8< -------------------------------------- Steps to Reproduce: 1. Run that script. Actual results: Files starting with both lowercase and uppercase letters are listed. Expected results: Only files starting with lowercase letters are listed. Additional info: Works just fine (i.e., lists only the correct files) if you cut and paste the commands into an interactive bash shell. Also works with zsh (unchanged) and csh/tcsh (with appropriate modifications).
Ok, I know what's coming (after doing another bug search that was more fruitful). The question then becomes: why does RHAS 2.1 use a default setting for LANG (en_US, in this case) that produces such badly broken bash behavior?
And, which is the correct (or preferred) fix: setting LANG=C, setting LC_COLLATE=C, or both? And what are the downsides? If RHAS 2.1 sets those defaults (which we haven't touched since the installation), surely there must be some good reason for it, considering the extreme damage that can result from having file globs behave in this manner.
Reassigning to distribution, since this is not to do with bash.
And, why does the behavior differ between an interactive bash shell and a bash script? I checked the environment in each instance, and in both cases LANG was set to en_US; in fact the only difference between the environment for the interactive bash shell and the script was the SHLVL variable. Surely the behavior should at least be consistent if the environment variables are the same?
Is there any reason why [A-Z] or [a-z] are dependent on the LANG setting? The LANG setting is useful in some aspects. However, if the regular expressions are broken afterwards,... BTW. [A-Z] also includes the lower case letters.
Bugzilla clean up. Closing. RHEL 2.1 is in maint mode. Fixed in later versions of RHEL.