Please copy the following to a file test.sh
************************************************************
#!/bin/bash
rx='(wlan)(1)'
if [[ 'wlan1' =~ $rx ]]; then
echo 'if returned 0'
echo ${BASH_REMATCH[0]}
echo ${BASH_REMATCH[1]}
echo ${BASH_REMATCH[2]}
echo ${#BASH_REMATCH}
echo ${#BASH_REMATCH[0]}
echo ${#BASH_REMATCH[1]}
echo ${#BASH_REMATCH[2]}
echo 'yet ${BASH_REMATCH} is empty when run using bashdb'
fi
*************************************************************
and then run
>chmod a+x test.sh
>./test.sh
and see the output as expected
*************************************************************
if returned 0
wlan1
wlan
1
5
5
4
1
yet ${BASH_REMATCH} is empty when run using bashdb
>
*************************************************************
next, please run
>bashdb test.sh
bashdb<0> n
bashdb<1> n
bashdb<2> n
bashdb<3> print ${BASH_REMATCH[0]}
and you will see that in bashdb BASH_REMATCH is an empty string. It appears the
debugger is broken and has probably been so for some time. Could I be doing
something wrong?