John E. Wulff wrote: > I have just updated from "openSUSE 10.2" to openSUSE 11.0" Linux. My > backup shell script > is now broken. I tracked the problen down to the latest version of > "bash". > > The relatively new binary operator =~ does not match a regular > expression which contains a > character class in square brackets: eg. $xp =~ "[0-9]10" > > The behaviour is the same on a 32 bit machine with openSUSE 11.0 and > GNU bash, version 3.2.39(1)-release (i586-suse-linux-gnu) > > All three script lines below match correctly on SuSE Linux 9.3 with > GNU bash, version 3.00.16(1)-release (i586-suse-linux) > > Unfortunately I no longer have access to the bash version which worked > correctly with openSUSE 10.2 > > My observation is the fault was introduced fairly recently. > > Repeat-By: > The following very simple regular expression matches: > xp=310; if [[ $xp =~ "310" ]]; then echo "$xp matched"; else echo "$xp > not matched"; fi > > This does not match in Bash Version 3.2 > xp=310; if [[ $xp =~ "[0-9]10" ]]; then echo "$xp matched"; else echo > "$xp not matched"; fi > > This does not match either (more like the line in my broken shell > script) > xp=310; if [[ $xp =~ "[0-9][0-9]*" ]]; then echo "$xp matched"; else > echo "$xp not matched"; fi
That has been discussed some days ago, it's the expected behavior. See http://lists.gnu.org/archive/html/bug-bash/2008-06/msg00083.html -- D.