X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org MIME-Version: 1.0 In-Reply-To: <26503748.post@talk.nabble.com> References: <26500158 DOT post AT talk DOT nabble DOT com> <26500814 DOT post AT talk DOT nabble DOT com> <4B0C4C2A DOT 3080502 AT gmail DOT com> <26503748 DOT post AT talk DOT nabble DOT com> From: Hugh Myers Date: Tue, 24 Nov 2009 14:54:29 -0700 Message-ID: <408995400911241354p27f2c5eek94973673d24fa3b3@mail.gmail.com> Subject: Re: Cygwin bash regexp matching doesn't treat "\b" properly To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com This might come across as slightly smart-assed, but if you wrote your script in Perl, you wouldn't have the platform problem, nor the word-boundary problem. True you would have a Perl problem, but that would still be several orders of magnitude easier than trying to have Linux, Cygwin and Posix come to agreement!! :) --hsm On Tue, Nov 24, 2009 at 2:40 PM, aputerguy wrote: > > Dave Korn writes: > >> Bash man page for '~=3D' refers to man regex(3) which refers to man rege= x(7) >> which describes word boundary markers as below: >> >> $ [[ "foo" =3D~ [[:\<:]]foo[[:\>:]] ]]; echo $? >> 0 >> >> $ [[ "foobar" =3D~ [[:\<:]]foo[[:\>:]] ]]; echo $? >> 1 > > Thanks David! > I had actually greppe'd both regex(3) and regex(7) before but I was looki= ng > for the word "word" or "boundary" - neither of which are used in this > context. > > HOWEVER, this solution while sweet for cygwin-bash, has the CONVERSE > PROBLEM. > Apparently, the special strings [[:<:]] and [[:>:]] are not recognized un= der > Linux regex(7) - they give return code 2. > > So, now I have the frustrating situation where \\b works in Linux but not= in > Cygwin while [[:<:]] works in Cygwin but not in Linux. > > BTW, both regex(7) pages even imply they are POSIX. > Linux: "regex POSIX.2 regular expressions" > Cygwin: "regex - POSIX 1003.2 regular expressions" > > Such incompatibility is a PITA because then in a mixed Windows/Linux > environment one has to remember to clutter scripts with ugly "if [ "$OSTY= PE" > =3D "cygwin" ] exceptions, etc. > > > > -- > View this message in context: http://old.nabble.com/Cygwin-bash-regexp-ma= tching-doesn%27t-treat-%22%5Cb%22-properly-tp26500158p26503748.html > Sent from the Cygwin list mailing list archive at Nabble.com. > > > -- > Problem reports: =A0 =A0 =A0 http://cygwin.com/problems.html > FAQ: =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 http://cygwin.com/faq/ > Documentation: =A0 =A0 =A0 =A0 http://cygwin.com/docs.html > Unsubscribe info: =A0 =A0 =A0http://cygwin.com/ml/#unsubscribe-simple > > -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple