delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/01/11/11:39:39

X-Spam-Check-By: sourceware.org
Date: Thu, 11 Jan 2007 08:37:48 -0800
From: David Rothenberger <daveroth AT acm DOT org>
Subject: Re: Bash regex tests wh'appen?
In-reply-to: <013b01c7359a$96ecb740$a501a8c0@CAM.ARTIMI.COM>
To: cygwin <cygwin AT cygwin DOT com>
Message-id: <45A667DC.40609@acm.org>
MIME-version: 1.0
References: <013b01c7359a$96ecb740$a501a8c0 AT CAM DOT ARTIMI DOT COM>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.9) Gecko/20061207 Thunderbird/1.5.0.9 Mnenhy/0.7.4.666
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list 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 AT daveroth DOT dyndns DOT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019