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


Groups > gnu.bash.bug > #12053 > unrolled thread

Why I love bash scripting?

Started byken.w.martin@gmail.com
First post2015-12-20 05:44 -0800
Last post2015-12-21 16:16 -0500
Articles 3 — 3 participants

Back to article view | Back to gnu.bash.bug


Contents

  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

#12053 — Why I love bash scripting?

Fromken.w.martin@gmail.com
Date2015-12-20 05:44 -0800
SubjectWhy I love bash scripting?
Message-ID<27da3e1b-84ae-4cbb-ac35-116b564d3e88@googlegroups.com>
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?

[toc] | [next] | [standalone]


#12056

FromEduardo A. Bustamante López <dualbus@gmail.com>
Date2015-12-20 23:52 -0600
Message-ID<mailman.286.1450677152.843.bug-bash@gnu.org>
In reply to#12053
bashdb is maintained separate from bash, by a different person:
http://bashdb.sourceforge.net/

[toc] | [prev] | [next] | [standalone]


#12074

FromChet Ramey <chet.ramey@case.edu>
Date2015-12-21 16:16 -0500
Message-ID<mailman.346.1450732575.843.bug-bash@gnu.org>
In reply to#12053
On 12/20/15 8:44 AM, ken.w.martin@gmail.com wrote:

> 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?

It's most likely that bashdb uses the =~ operator for its own purposes
and overwrites the BASH_REMATCH contents you want to see.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/

[toc] | [prev] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web