bug-bash
[Top][All Lists]
Advanced

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

Regular expression matching fails with string RE


From: carson
Subject: Regular expression matching fails with string RE
Date: Tue, 16 Oct 2012 14:18:40 -0700 (PDT)

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: solaris2.11
Compiler: cc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='solaris2.11' -DCONF_MACHTYPE='i386-pc-solaris2.11' 
-DCONF_VENDOR='pc' 
-DLOCALEDIR='/Tools/SunOS_5.11_i86pc_amd64/bash-4.2p37/share/locale' 
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DSOLARIS   -I.  -I. -I./include 
-I./lib   -m64 -xO5 -xchip=sandybridge -xarch=sse4_2 -xarch=avx -xarch=aes
uname output: SunOS gandalf.local.taltos.org 5.11 11.0 i86pc i386 i86pc
Machine Type: i386-pc-solaris2.11

Bash Version: 4.2
Patch Level: 37
Release Status: release

Description:
The [[ =~ operator fails if the RE is supplied as a string instead of a variable

Repeat-By:
bash -c 're=".*([0-9])"; if [[ "foo1" =~ ".*([0-9])" ]]; then echo 
${BASH_REMATCH[0]}; elif [[ "bar2" =~ $re ]]; then echo ${BASH_REMATCH[0]}; fi'

This should output foo1. It instead outputs bar2, as the first match fails.




reply via email to

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