bug-bash
[Top][All Lists]
Advanced

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

Regular expressions with word boundaries no longer working in bash


From: Harry Leitzell
Subject: Regular expressions with word boundaries no longer working in bash
Date: Fri, 17 Dec 2010 11:00:53 -0600

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-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2 -Wall
uname output: Linux ochof070 2.6.35-24-generic #42-Ubuntu SMP Thu Dec 2 
02:41:37 UTC 2010 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.1
Patch Level: 5
Release Status: release

Description:

Doing string matching based on word boundaries no longer works:

$ bash --version
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

$ cat test.sh
input="foocombo foo foo bar bar foo bar some stuff foo" # the input
expected="foocombo foo bar some stuff" # this what we expect
for i in address@hidden; do
    [[ ! address@hidden =~ \\b"${i}"\\b ]] && old=( address@hidden $i )
done
for i in address@hidden; do
    [[ ! address@hidden =~ \b${i}\b ]] && new=( address@hidden $i )
done
echo "input:    $input"
echo "expected: $expected"
echo "old code: ${old[*]}"
echo "new code: ${new[*]}"

$ bash test.sh
input:    foocombo foo foo bar bar foo bar some stuff foo
expected: foocombo foo bar some stuff
old code: foocombo foo bar some stuff
new code: foocombo foo foo bar bar foo bar some stuff foo


Repeat-By:

$ bash --version
GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ cat test.sh
input="foocombo foo foo bar bar foo bar some stuff foo" # the input
expected="foocombo foo bar some stuff" # this what we expect
for i in address@hidden; do
    [[ ! address@hidden =~ \\b"${i}"\\b ]] && old=( address@hidden $i )
done
for i in address@hidden; do
    [[ ! address@hidden =~ \b${i}\b ]] && new=( address@hidden $i )
done
echo "input:    $input"
echo "expected: $expected"
echo "old code: ${old[*]}"
echo "new code: ${new[*]}"

$ bash test.sh
input:    foocombo foo foo bar bar foo bar some stuff foo
expected: foocombo foo bar some stuff
old code: foocombo foo foo bar bar foo bar some stuff foo
new code: foocombo foo foo bar bar foo bar some stuff foo

The information in this e-mail is intended only for the person or entity to 
which it is addressed.

It may contain confidential and /or privileged material.  If someone other than 
the intended recipient should receive this e-mail, he / she shall not be 
entitled to read, disseminate, disclose or duplicate it.

If you receive this e-mail unintentionally, please inform us immediately by 
"reply" and then delete it from your system. Although this information has been 
compiled with great care, neither IMC Financial Markets & Asset Management nor 
any of its related entities shall accept any responsibility for any errors, 
omissions or other inaccuracies in this information or for the consequences 
thereof, nor shall it be bound in any way by the contents of this e-mail or its 
attachments.  In the event of incomplete or incorrect transmission, please 
return the e-mail to the sender and permanently delete this message and any 
attachments.

Messages and attachments are scanned for all known viruses. Always scan 
attachments before opening them.



reply via email to

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