This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with Bash regex test case sensitivity


On 2010-12-03 22:30Z, Lee Rothstein wrote:
[script:]
> if [[ "$1" =~ [A-Z] ]] ; then
>      echo Contains Capital Letters: $1
> else
>      echo Doesn\'t Contain Capital Letters: $1
> fi
[...]
> # WTF, O
> $ t_regex dfgh
> Contains Capital Letters: dfgh

Inspect this option:
  shopt -p | grep nocasematch
Perhaps you have it set in your startup files?

Example of different 'nocasematch' settings with the same command:

$ shopt -u nocasematch
$ if [[ "a" =~ [A-Z] ]] ; then echo UPPER; else echo lower; fi
lower

$ shopt -s nocasematch
$ if [[ "a" =~ [A-Z] ]] ; then echo UPPER; else echo lower; fi
UPPER

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]