Re: Inconsistent regex matching with =~ between bash 3.1 and 3.2
From:
Paul Jarc
Subject:
Re: Inconsistent regex matching with =~ between bash 3.1 and 3.2
Date:
Wed, 11 Jul 2007 13:10:59 -0400
User-agent:
Gnus/5.110003 (No Gnus v0.3) Emacs/21.4 (gnu/linux)
Scott Carpenter <scottc@movingtofreedom.org> wrote:
> V="one/two"
> [[ ! $V =~ ^\.*/ ]] && echo not
3.1 will remove the backslash as part of basic string parsing, just as
if this were not part of a [[ command, while 3.2 handles the arguments
for [[ specially, and will keep the backslash as part of the regexp.
This will work in both versions:
pattern='^\.*/'
[[ ! $V =~ $pattern ]] && echo not
paul