bug-bash
[Top][All Lists]
Advanced

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

Re: regex confusion -- not matching; think it should?


From: Linda Walsh
Subject: Re: regex confusion -- not matching; think it should?
Date: Wed, 19 Jun 2013 10:53:02 -0700
User-agent: Thunderbird



DJ Mills wrote:
On Wed, Jun 12, 2013 at 6:53 PM, Linda Walsh <bash@tlinx.org <mailto:bash@tlinx.org>> wrote:

    The trace looks aprolike this:

            ./ifc#137(handle_bonding_ops)> (( 18>3 ))
            ./ifc#138(handle_bonding_ops)> [[  mode=balance-rr 0 =~

^([a-zA-Z][-a-zA-Z0-9_]+)=(.+)__[[:space:]]+[a-zA-Z][-a-zA-Z0-__9_]+=.+.*$
    ]]

            ./ifc#142(handle_bonding_ops)> [[  mode=balance-rr 0 =~
            ^([a-zA-Z][-a-zA-Z0-9_]+)=(.+)__$ ]]
            ./ifc#145(handle_bonding_ops)> break


    (#138 is all 1 line)
    ---- the source code looks like this:

      my id='[a-zA-Z][-a-zA-Z0-9_]+'
      while ((${#bond_ops}>3)); do
        if [[ $bond_ops =~ ^($id)=(.+)[[:space:]]+$id=.+.__*$ ]]; then
          ...
        elif [[ "$bond_ops" =~ ^($id)=(.+)$ ]]; then
         ...
        else break; fi

    ---
    I would think the 2nd match would match it, but no luck...
    Note the 2nd source line has double quotes due to testing...
    Originally it had no quotes, as I don't believe they are
    necessary in this case.  Regardless, neither way matches.

    So if not obvious, bond_ops has "mode=balance-rr 0" in it.

    Thanks...



Just FYI, you should be using [[:alpha:]] and [[:alnum:]], as they're safe for all locales.
----
        Since this is for the linux kernel, I'd be better off
just using locale=C;  As for the quotes .. see the 2nd and 3rd lines
of the bottom paragraph...;-)


 You can't count on a-z or A-Z unless the locale is
C or POSIX. And no, quotes on the LHS of [[ are not needed, as wordsplitting and pathname expansion do not occur within the [[ keyword.



reply via email to

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