Matching regular expression with Ctrl-A in the middle
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_GNU_SOURCE -DRECYCLES_PIDS -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic uname output: Linux dev1 2.6.35.6-45.fc14.x86_64 #1 SMP Mon Oct 18 23:57:44 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-redhat-linux-gnu Bash Version: 4.1 Patch Level: 7 Release Status: release Description: I have a regular expression with a Ctrl-A character in the middle and I can no longer get it to match with bash 4.1.7. However I can get regular expressions to match as long as the Ctrl-A is at the beginning or end of the regular expression so I suspect this is a bug. Using 'shopt -s compat31' does allow the match to occur with a Ctrl-A in the middle but I'd prefer to not use this if I don't have to. Repeat-By: -bash-4.1$ [[ "helloworld" =~ llo ]] && echo match match -bash-4.1$ [[ "helloworld" =~ world ]] && echo match match -bash-4.1$ [[ "helloworld" =~ world$ ]] && echo match match -bash-4.1$ [[ "helloworld" =~ ]] && echo match match -bash-4.1$ [[ "helloworld" =~ oworld$ ]] && echo match -bash-4.1$ shopt -s compat31 -bash-4.1$ [[ "helloworld" =~ oworld$ ]] && echo match match
Re: Matching regular expression with Ctrl-A in the middle
On Thu, May 5, 2011 at 3:47 PM, Chet Ramey wrote: > On 5/4/11 11:23 AM, Shawn Bohrer wrote: >> Configuration Information [Automatically generated, do not change]: >> Machine: x86_64 >> OS: linux-gnu >> Compiler: gcc >> Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' >> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-redhat-linux-gnu' >> -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' >> -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_GNU_SOURCE >> -DRECYCLES_PIDS -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions >> -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic >> uname output: Linux dev1 2.6.35.6-45.fc14.x86_64 #1 SMP Mon Oct 18 23:57:44 >> UTC 2010 x86_64 x86_64 x86_64 GNU/Linux >> Machine Type: x86_64-redhat-linux-gnu >> >> Bash Version: 4.1 >> Patch Level: 7 >> Release Status: release >> >> Description: >> >> I have a regular expression with a Ctrl-A character in the middle and I >> can no longer get it to match with bash 4.1.7. However I can get >> regular expressions to match as long as the Ctrl-A is at the beginning >> or end of the regular expression so I suspect this is a bug. > > Try the attached patch. It's against bash-4.2, but the bash-4.1 code is > substantially similar. Thanks Chet! I verified that your patch resolves the issue for me on both bash 4.1 and 4.2. -- Shawn --- This email, along with any attachments, is confidential. If you believe you received this message in error, please contact the sender immediately and delete all copies of the message. Thank you.