Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #12053

Why I love bash scripting?

Newsgroups gnu.bash.bug
Date 2015-12-20 05:44 -0800
Message-ID <27da3e1b-84ae-4cbb-ac35-116b564d3e88@googlegroups.com> (permalink)
Subject Why I love bash scripting?
From ken.w.martin@gmail.com

Show all headers | View raw


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?

Back to gnu.bash.bug | Previous | NextNext in thread | Find similar


Thread

Why I love bash scripting? ken.w.martin@gmail.com - 2015-12-20 05:44 -0800
  Re: Why I love bash scripting? Eduardo A. Bustamante López <dualbus@gmail.com> - 2015-12-20 23:52 -0600
  Re: Why I love bash scripting? Chet Ramey <chet.ramey@case.edu> - 2015-12-21 16:16 -0500

csiph-web