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: Dan Douglas
Subject: Re: regex confusion -- not matching; think it should?
Date: Wed, 19 Jun 2013 18:12:57 -0500
User-agent: KMail/4.10.4 (Linux/3.9.5-pf+; KDE/4.10.4; x86_64; ; )

On Wednesday, June 19, 2013 12:29:55 PM DJ Mills wrote:
> On Wed, Jun 12, 2013 at 6:53 PM, Linda Walsh <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. 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.

Where does it say that you can count on [[:alpha:]] being the same in non-POSIX
locales? I see it defined for the POSIX locale.

Thanks to mksh, posh, etc not supporting POSIX character classes at all, I'm
not so sure it's actually better in practice. (talking about standard shell
pattern matching of course)

-- 
Dan Douglas



reply via email to

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