bug-bash
[Top][All Lists]
Advanced

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

Re: Bash-3.2 Official Patch 10


From: Kevin F. Quinn
Subject: Re: Bash-3.2 Official Patch 10
Date: Mon, 12 Mar 2007 08:40:54 +0100

On Fri, 09 Mar 2007 11:39:18 -0500
Chet Ramey <chet.ramey@case.edu> wrote:

> Kevin F. Quinn wrote:
> > On Mon, 5 Mar 2007 17:49:47 -0500
> > Chet Ramey <chet.ramey@case.edu> wrote:
> > 
> >> Bash-Release: 3.2
> >> Patch-ID: bash32-010
> > 
> > I'm still seeing a difference in behaviour:
> 
> Yes.  That's the difference between the undefined quoting semantics
> in bash-3.1 and the defined semantics in bash-3.2.  In bash-3.2, the
> quoting removes all meaning from any characters special to the regular
> expression engine.
> 
> > 
> > To get the 3.2 results, I expected to have to write:
> > 
> > [[ ${v} =~ "\^Alpha" ]] && echo match 4 || echo no match 4
> > [[ ${v} =~ '\^Alpha' ]] && echo match 5 || echo no match 5
> 
> Why?

I guess I've gotten into the habit of putting any text string in
double-quotes to avoid having to quote things like spaces, or
single-quotes to avoid having to quote $ as well.

Actually, I didn't expect to _have_ to write it like that, just that it
would be possible; e.g. that the following would be equivalent:

\^Alpha\ Beta
"\^Alpha Beta"
'^Alpha Beta'
    (thinking now that perhaps ^ would lose its special meaning in '')

in order to match the literal string `^Alpha Beta' - i.e. without
special meaning to ^.

>  The 3.2 behavior means that the match is performed on the
> literal string `\^Alpha', with the backslash and circumflex quoted to
> protect them from interpretation by the regexp matching engine.
> That's the difference.

So effectively, the new rule is that all the regex special characters
lose their special meaning when placed in double or single quotes (much
like '$' does inside single quotes).


Thanks for the clarification.

-- 
Kevin F. Quinn

Attachment: signature.asc
Description: PGP signature


reply via email to

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