3 # Test correct functioning bash debug support not via the bashdb
4 # debugger but merely by printing via print_trap()
5 # $Id: dbg-support.tests,v 1.13 2003/02/17 22:02:25 rockyb Exp $
8 echo "debug lineno: $1 ${FUNCNAME[1]}"
13 echo "return lineno: $1 ${FUNCNAME[1]}"
20 echo "BASH_SOURCE[0]" ${BASH_SOURCE[0]}
21 echo "FUNCNAME[0]" ${FUNCNAME[0]}
29 echo "fn2 here. Calling fn1..."
35 echo "BASH_SOURCE[0]" ${BASH_SOURCE[0]}
40 for (( i=0 ; (( i < $n )) ; i++ )) ; do
42 [ $j -eq $n ] && j=i # main()'s file is the same as the first caller
43 echo "${FUNCNAME[$i]} called from file " \
44 "\`${BASH_SOURCE[$j]}' at line ${BASH_LINENO[$j]}"
46 source ./dbg-support.sub
50 echo "fn4 here. Calling fn3..."
57 # Test of support for debugging facilities in bash
59 # Test debugger set option functrace - set on. Not in vanilla Bash 2.05
62 trap 'print_debug_trap $LINENO' DEBUG
63 trap 'print_return_trap $LINENO' RETURN
65 # Funcname is now an array, but you still can't see it outside a function
66 echo "FUNCNAME" ${FUNCNAME[0]:-main}
68 # We should trace into the below.
69 # Start easy with a simple function.
73 source ./dbg-support.sub
75 # Test debugger set option functrace - set off
78 # We should not trace into this.
83 source ./dbg-support.sub
85 # Another way to say: set -o functrace
88 # We should trace into this.
89 source ./dbg-support.sub
92 # Test that the line numbers in the presence of conditionals are correct.
93 for (( i=0 ; (( i <= 2 )) ; i++ )) ; do
94 if [ $i -eq 2 ] ; then
101 # Check line numbers in command substitution
108 # Make sure we step into sourced_fn as a comand when we request to do so.
109 # Vanilla bash 2.0 doesn't do.
113 # Should see line number of xyzzy below. Vanilla bash 2.05b doesn't do
124 * ) echo "no good" ;;
130 # Should see line numbers for initial for lines.
137 ${THIS_SH} ./dbg-support3.sub
139 #;;; Local Variables: ***
140 #;;; mode:shell-script ***
141 #;;; eval: (sh-set-shell "bash") ***