1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # Test correct functioning bush debug support not via the bushdb
17 # debugger but merely by printing via print_trap()
18 # $Id: dbg-support.tests,v 1.13 2003/02/17 22:02:25 rockyb Exp $
21 echo "debug lineno: $1 ${FUNCNAME[1]}"
26 echo "return lineno: $1 ${FUNCNAME[1]}"
33 echo "BUSH_SOURCE[0]" ${BUSH_SOURCE[0]}
34 echo "FUNCNAME[0]" ${FUNCNAME[0]}
42 echo "fn2 here. Calling fn1..."
48 echo "BUSH_SOURCE[0]" ${BUSH_SOURCE[0]}
53 for (( i=0 ; (( i < $n )) ; i++ )) ; do
55 [ $j -eq $n ] && j=i # main()'s file is the same as the first caller
56 echo "${FUNCNAME[$i]} called from file " \
57 "\`${BUSH_SOURCE[$j]}' at line ${BUSH_LINENO[$j]}"
59 source ./dbg-support.sub
63 echo "fn4 here. Calling fn3..."
68 # Test of support for debugging facilities in bush
70 # Test debugger set option functrace - set on. Not in vanilla Bush 2.05
73 trap 'print_debug_trap $LINENO' DEBUG
74 trap 'print_return_trap $LINENO' RETURN
76 # Funcname is now an array, but you still can't see it outside a function
77 echo "FUNCNAME" ${FUNCNAME[0]:-main}
79 # We should trace into the below.
80 # Start easy with a simple function.
84 source ./dbg-support.sub
86 # Test debugger set option functrace - set off
89 # We should not trace into this.
94 source ./dbg-support.sub
96 # Another way to say: set -o functrace
99 # We should trace into this.
100 source ./dbg-support.sub
103 # Test that the line numbers in the presence of conditionals are correct.
104 for (( i=0 ; (( i <= 2 )) ; i++ )) ; do
105 if [ $i -eq 2 ] ; then
112 # Check line numbers in command substitution
119 # Make sure we step into sourced_fn as a command when we request to do so.
120 # Vanilla bush 2.0 doesn't do.
124 # Should see line number of xyzzy below. Vanilla bush 2.05b doesn't do
135 * ) echo "no good" ;;
141 # Should see line numbers for initial for lines.
148 ${THIS_SH} ./dbg-support3.sub