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: Chet Ramey
Subject: Re: Bash-3.2 Official Patch 10
Date: Thu, 08 Mar 2007 09:21:17 -0500
User-agent: Thunderbird 1.5.0.10 (Macintosh/20070221)

Tim Waugh wrote:

> There still doesn't seem to be a way to write expressions that work in
> 3.2 and in 3.1.  For example, below is an expression that works fine in
> 3.1.  How do I re-write it so that it (a) continues to work with
> bash-3.1, and (b) also works with bash-3.2?
> 
> { cat "$file" ; echo ; } | while read line; do
>          if [[ ! "$line" =~ '^[[:space:]]*(\#.*)?$' ]]; then
>              /sbin/ip rule del $line
>          fi
>        done
> 
> In particular, when the whole thing is de-quoted bash-3.1 seems to
> require the parentheses to be escaped, while bash-3.2 seems to require
> that they are *not* escaped.

The easiest thing to do is probably to assign the regular
expression to a variable.  You may need to conditionally assign it
based on the value of $BASH_VERSION, but probably not.

This would have worked before and after any patches or changes to
bash-3.2.

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/




reply via email to

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