bug-bash
[Top][All Lists]
Advanced

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

bash 3.2 match operator problem


From: John Gatewood Ham
Subject: bash 3.2 match operator problem
Date: Thu, 12 Oct 2006 13:45:59 +0700 (ICT)

Configuration Information [Automatically generated, do not change]:
Machine: i586
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i586' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i586-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include\ -I./lib -O2 -march=i586 -mtune=i686 uname output: Linux zappaman.cs.buu.ac.th 2.6.16.29 #1 Sat Sep 16 13:10:25 ICT 2006 i686 pentium3 i386 GNU/Linux
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





reply via email to

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