File: wvtest-bash.sh

package info (click to toggle)
bup 0.29-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,028 kB
  • sloc: sh: 8,287; python: 7,077; ansic: 1,415; pascal: 664; makefile: 239; perl: 219
file content (32 lines) | stat: -rw-r--r-- 590 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

declare -a _wvbtstack

_wvpushcall()
{
    _wvbtstack[${#_wvbtstack[@]}]="$*"
}

_wvpopcall()
{
    unset _wvbtstack[$((${#_wvbtstack[@]} - 1))]
}

_wvbacktrace()
{
    local i loc
    local call=$((${#_wvbtstack[@]} - 1))
    for ((i=0; i <= ${#FUNCNAME[@]}; i++)); do
	local name="${FUNCNAME[$i]}"
	if test "${name:0:2}" == WV; then
            loc="${BASH_SOURCE[$i+1]}:${BASH_LINENO[$i]}"
	    echo "called from $loc ${FUNCNAME[$i]} ${_wvbtstack[$call]}" 1>&2
	    ((call--))
	fi
    done
}

_wvfind_caller()
{
    WVCALLER_FILE=${BASH_SOURCE[2]}
    WVCALLER_LINE=${BASH_LINENO[1]}
}