Machine Type: i586-pc-linux-gnu
Bash Version: 3.2
Patch Level: 0
Release Status: release
Description:
I just upgraded to bash 3.2 and my scripts quit working for matching.
The test case below will say 'Life is good' in bash 3.1.17, but on bash
3.2 I get 'Upgrade of doom returns 2 from match' instead.
The bash.info manual does not include examples for regex. The man
page they refer to does not include examples for regex. I am
aware perhaps my regex is imperfect, but hopefully this testcase
can show you easily what I expected, and it did work for bash 3.1.17.
I am willing to recode the script, but I need help to know how
the '=~' behaves in the new bash 3.2 version, and how to modify
this script to populate BASH_REMATCH with element 1 as
jbig2dec, element 2 as 0.9, element 3 as i586, and element 4
as 001, just as it worked well with bash 3.1.17
Repeat-By:
#!/bin/bash
set -u
echo "testcase running under ${BASH_VERSION}"
OLDCANDIDATE="/tmp/jbig2dec-0.9-i586-001.tgz"
OLDCANDIDATE="${OLDCANDIDATE##*/}" # remove leading path
[[ "${OLDCANDIDATE}" =~ "([^-]+)-([^-]+)-([^-]+)-0*([1-9][0-9]*)\.tgz" ]]
REZ=$?
case ${REZ} in
0) STEM="${BASH_REMATCH[1]}"
;;
1) STEM="Unknown"
;;
*) echo "Upgrade of doom returns ${REZ} from match"
exit 1
esac
if [[ "${STEM}" == "jbig2dec" ]]
then
echo "Life is good"
else
echo "Upgrade of doom cannot process my regex"
fi
exit 0