1# kshdb - Korn Shell Debugger main file 2# adapted from 'Learning the Korn Shell' by Bill Rosenblatt (O'Reilly) 3# by Cigy Cyriac (cigy@felix.tulblr.unisys.com) 4# Main driver: constructs full script (with preamble) and runs it 5 6echo 'Bourne-Again Shell Debugger version 0.1' 7 8_pname=${0##*/} 9 10[ $# -eq 0 ] && { 11 echo "${_pname}: usage: ${_pname} <script_file>" 12 exit 1 13} 14 15_guineapig=$1 16 17[ -r $_guineapig ] || { 18 echo "${_pname}: cannot read $_guineapig." >&2 19 exit 1 20} 21shift 22 23_tmpdir=/tmp 24_libdir=. 25_dbgfile=$_tmpdir/bashdb$$ #temp file for script being debugged 26 27cat $_libdir/bashdb.pre $_guineapig > $_dbgfile 28if [ -f "$BASH" ]; then 29 exec $BASH $_dbgfile $_guineapig $_tmpdir $_libdir "$@" 30else 31 exec bash $_dbgfile $_guineapig $_tmpdir $_libdir "$@" 32fi 33# end of bashdb 34