bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Regular expression match operation with character classes fails in bash


From: John E. Wulff
Subject: Regular expression match operation with character classes fails in bash 3.2
Date: Fri, 27 Jun 2008 10:45:45 +0200
User-agent: Thunderbird 2.0.0.14 (Windows/20080421)

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc -I/usr/src/packages/BUILD/bash-3.2 -L/usr/src/packages/BUILD/bash-3.2/../readline-5.2 Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-suse-linux-gnu' -DCONF_VENDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -O2 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -g -D_GNU_SOURCE -DRECYCLES_PIDS -Wall -g -std=gnu89 -Wextra -Wno-unprototyped-calls -Wno-switch-enum -pipe -fPIE -fprofile-use uname output: Linux umina 2.6.25.5-1.1-default #1 SMP 2008-06-07 01:55:22 +0200 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-suse-linux-gnu

Bash Version: 3.2
Patch Level: 39
Release Status: release

Description:
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

This message was generated with openeSUSE 11.0 Linux and sent with Thunderbird.

Best regards - John E. Wulff





reply via email to

[Prev in Thread] Current Thread [Next in Thread]