Boost logo

Boost-Build :

Subject: Re: [Boost-build] MATCH regular expression issue
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2011-02-13 09:32:48


AMDG

On 2/12/2011 11:38 PM, Bryce Lelbach (wash) wrote:
>
> The documentation for MATCH (bjam builtin rules) states:
>
> "Matches the egrep(1) style regular expressions [...]"
>
> This is not entirely accurate.
>
> if [ MATCH "12[.]0|12" : "11.0" ] { ECHO "version 12" ; } # does not echo
> if [ MATCH "12[.]0|12" : "12.0" ] { ECHO "version 12" ; } # does not echo
> if [ MATCH "(12[.]0|12)" : "12.0" ] { ECHO "version 12" ; } # echoes
>
> egrep is command-line syntactic sugar for `grep -E' (extended regular
> expression, specified in POSIX, aka ERE). The above behavior (aka the failure
> to match w/o parens) does not match the behavior described by POSIX or
> implemented by well known grep distros:
>
> wash_at_pegasus:~/boost$ egrep --version
> GNU grep 2.6.3
>
> 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.
>
> wash_at_pegasus:~/boost$ echo "11" | egrep "12[.]0|12"
> wash_at_pegasus:~/boost$ echo "12.0" | egrep "12[.]0|12"
> 12.0
> wash_at_pegasus:~/boost$ echo "12.0" | egrep "(12[.]0|12)"
> 12.0
>
> I do not understand why I need to add the parens in bjam. Is this a bug? Is this
> intention? Either way, can we either change this behavior, or change the docs?
>

This is the expected behavior. MATCH doesn't
return a boolean value, it returns the captures,
which are specified by parentheses. If there
are no parentheses, nothing is captured, and
the return value is empty which is evaluated
as false.

In Christ,
Steven Watanabe


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk