This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Bash regex tests wh'appen?
- From: David Rothenberger <daveroth at acm dot org>
- To: cygwin <cygwin at cygwin dot com>
- Date: Thu, 11 Jan 2007 08:37:48 -0800
- Subject: Re: Bash regex tests wh'appen?
- References: <013b01c7359a$96ecb740$a501a8c0@CAM.ARTIMI.COM>
- Reply-to: cygwin at cygwin dot com
On 1/11/2007 8:07 AM, Dave Korn wrote:
I upgraded quite a lot of bash versions in one go, and one of my
shell-scripts broke. I've reproduced it to a simple test case which shows
that either regex tests have turned into non-reg-ex text matches, or that I've
really misunderstood something here. I checked the last few release
announcements and didn't see anything about the behaviour of =~ changing.
It's mentioned in /usr/share/doc/bash-3.2.9/CHANGES:
f. Quoting the string argument to the [[ command's =~
operator now forces string matching, as with the
other pattern-matching operators.
Also, I believe the unquoted pattern is already protected from expansion
of special characters, so you don't have to worry about *.
/artimi/tools/cygwin/bin $ if [[ "foo.h" =~ "foo.h" ]] ; then echo "yes" ;
[[ "foo.h" =~ foo.h ]]
/artimi/tools/cygwin/bin $ if [[ "foo.h" =~ ".*foo.h" ]] ; then echo "yes" ;
[[ "foo.h" =~ .*foo.h ]]
/artimi/tools/cygwin/bin $ if [[ "foo.h" =~ "\.\*foo.h" ]] ; then echo "yes" ;
[[ "foo.h" =~ \.\*foo.h ]]
--
David Rothenberger spammer? -> spam@daveroth.dyndns.org
GPG/PGP: 0x92D68FD8, DB7C 5146 1AB0 483A 9D27 DFBA FBB9 E328 92D6 8FD8
"The molars, I'm sure, will be all right, the molars can take care of
themselves," the old man said, no longer to me. "But what will become
of the bicuspids?"
-- The Old Man and his Bridge
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/