https://bugzilla.novell.com/show_bug.cgi?id=440861
Summary: no results from BASH_REMATCH Product: openSUSE 11.0 Version: Final Platform: Other OS/Version: Linux Status: NEW Severity: Normal Priority: P5 - None Component: Other AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: guenther.pommer@dhl.com QAContact: qa@suse.de Found By: Field Engineer
in SuSE 11 old scripts using "=~" (BASH_REMATCH) do not match any more - whereas expr does .
bash --version GNU bash, version 3.2.39(1)-release (i586-suse-linux-gnu) BASH_REMATCH
example script:
devnam=pdc_cacdecehha_part2 volnam=pdc_cacdecehha
[[ "$devnam" =~ "${volnam}_part([0-9])" ]] devpart=${BASH_REMATCH[1]}
echo "partition = $devpart" #--- gives bash nothing -> should be 2 ---
res=`expr "$devnam" : "${volnam}_part([0-9])"` echo $res #--- gives back 2 ---
https://bugzilla.novell.com/show_bug.cgi?id=440861
Cyril Hrubis chrubis@novell.com changed:
What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|bnc-team-screening@forge.provo.novell.com |werner@novell.com
https://bugzilla.novell.com/show_bug.cgi?id=440861
User werner@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=440861#c1
Dr. Werner Fink werner@novell.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |WONTFIX
--- Comment #1 from Dr. Werner Fink werner@novell.com 2008-11-07 08:21:12 MST --- Remove the double quotes
~> devnam=pdc_cacdecehha_part2 ~> volnam=pdc_cacdecehha ~> [[ $devnam =~ ${volnam}_part([0-9]) ]] ~> echo ${BASH_REMATCH[1]} 2
as I can read from the manual page bash(1) section `Compound Commands'
When the == and != operators are used, the string to the right of the operator is considered a pattern and matched according to the rules described below under Pattern Matching. If the shell option nocasematch is enabled, the match is performed without regard to the case of alphabetic characters. The return value is 0 if the string matches (==) or does not match (!=) the pattern, and 1 otherwise. Any part of the pattern may be quoted to force it to be matched as a string.
and I'll not change that as this is rthe way as upstream bash handles this.
https://bugzilla.novell.com/show_bug.cgi?id=440861
User werner@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=440861#c2
--- Comment #2 from Dr. Werner Fink werner@novell.com 2008-11-07 08:26:49 MST --- You may use the line
shopt -s compat31
as very first line after
#!/bin/bash
to switch back to old bash 3.1 behaviour.