[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Quoting near =~ is inconsistent
From: |
Chet Ramey |
Subject: |
Re: Quoting near =~ is inconsistent |
Date: |
Tue, 23 Jan 2007 17:38:45 -0500 |
User-agent: |
Thunderbird 1.5.0.9 (Macintosh/20061207) |
Tim Waugh wrote:
> Further to this, I am having trouble porting existing scripts to
> bash-3.2's new style of regex matching.
>
> Here is one example that is problematic: I want to use a character class
> in my regex, but bash seems to get confused by the ':]]' closing the
> class, and apparently takes it as a ']]' closing the conditional
> expression.
>
> Here is a distilled test case:
>
> [[ $line =~ [[:space:]]*(a)?b ]] && echo match || echo no match
>
> I used single quotes around the RHS in bash-3.1, which worked very well.
> How should this be written so as to work with bash-3.2 -- and, of
> course, still with bash-3.1?
It cannot; the level of backwards compatibility is not that great. I will
have to think about a solution.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Live Strong. No day but today.
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/