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: Tue, 6 Mar 2007 12:45:19 +0100

On Mon, 5 Mar 2007 17:49:47 -0500
Chet Ramey <address@hidden> wrote:

> Bash-Release: 3.2
> Patch-ID: bash32-010

I'm still seeing a difference in behaviour:

$ cat ~/bash-test
v="Alphabet"
[[ ${v} =~ "Alphabet" ]] && echo match 1 || echo no match 1
[[ ${v} =~ 'Alphabet' ]] && echo match 2 || echo no match 2
[[ ${v} =~ Alphabet ]] && echo match 3 || echo no match 3
[[ ${v} =~ "^Alpha" ]] && echo match 4 || echo no match 4
[[ ${v} =~ '^Alpha' ]] && echo match 5 || echo no match 5
[[ ${v} =~ ^Alpha ]] && echo match 6 || echo no match 6

bash 3.1.17(1):
$ source ~/bash-test
match 1
match 2
match 3
match 4
match 5
match 6

bash 3.2.10(1):
$ source ~/bash-test
match 1
match 2
match 3
no match 4
no match 5
match 6


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

(which is what I think bash-3.2_p10 is effectively doing)

I tried reading the posix standard (well, the single-unix specification
at opengroup.org, base definitions chapter 9 and shells & utilitis
chapter 2) but things are not so clear to me.  It still seems
counter-intuitive to me to have the regex characters auto-quoted in
single and double-quoted strings, just because they're the rhs of =~.
Doesn't happen if I pass one to grep, compare for example:

3.1:
$ v="Alphabet"
$ [[ ${v} =~ "^Alpha" ]] && echo matches
matches
$ echo ${v} | grep "^Alpha"
Alphabet

3.2.10
$ v="Alphabet"
$ [[ ${v} =~ "^Alpha" ]] && echo matches
$ echo ${v} | grep "^Alpha"
Alphabet


I guess the question is, is the difference between 3.2.10 and 3.1
semantics for the =~ rhs as described above intended?

-- 
Kevin F. Quinn

Attachment: signature.asc
Description: PGP signature


reply via email to

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