Menu

[69de4e]: / init / pre.sh  Maximize  Restore  History

Download this file

125 lines (102 with data), 3.9 kB

  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
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# -*- shell-script -*-
# pre.sh - Code common to bashdb and bashdb-trace that has to run first
#
# Copyright (C) 2002-2004, 2008-2012, 2018
# Rocky Bernstein <rocky@gnu.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to
# the Free Software Foundation, 59 Temple Place, Suite 330, Boston,
# MA 02111 USA.
# We put definitions common to both the script debugger and
# dbg-trace.sh. In contrast to other routines, this code is sourced
# early -- before most of the debugger script is run.
# Note: initializations which are mostly used in only one sub-part
# (e.g. variables for break/watch/actions) are in the corresponding
# file: either in lib or (less good) command.
# This function is overwritten by when lib/fns.sh gets loaded
_Dbg_msg()
{
echo >&2 "$@"
}
# This function is overwritten by when lib/fns.sh gets loaded
_Dbg_errmsg()
{
echo >&2 "${_Dbg_pname}: $@"
}
# Used by "show version" as well as --version
_Dbg_do_show_version()
{
[[ -n $1 ]] && label=$(_Dbg_printf_nocr "%-12s: " version)
_Dbg_msg "${label}$_Dbg_debugger_name, release $_Dbg_release"
}
# Expand filename given as $1.
# we echo the expanded name or return $1 unchanged if a bad filename.
# Return is 0 if good or 1 if bad.
# File globbing is handled.
# Note we don't check that the file exists, just that the format is
# valid; we do check that we can "search" the directory implied in the
# filename.
function _Dbg_expand_filename {
typeset -r filename="$1"
# Break out basename and dirname
typeset basename="${filename##*/}"
typeset -x dirname="${filename%/*}"
# No slash given in filename? Then use . for dirname
[[ $dirname == $basename ]] && [[ $filename != '/' ]] && dirname='.'
# Dirname is ''? Then use / for dirname
dirname=${dirname:-/}
# Handle tilde expansion in dirname
dirname=$(echo $dirname)
typeset long_path
[[ "$basename" == '.' ]] && basename=''
if long_path=$( (cd "$dirname" ; pwd) 2>/dev/null ) ; then
if [[ "$long_path" == '/' ]] ; then
echo "/$basename"
else
echo "$long_path/$basename"
fi
return 0
else
echo "$filename"
return 1
fi
}
# Create temporary file based on $1
# file $1
_Dbg_tempname() {
echo "$_Dbg_tmpdir/${_Dbg_debugger_name}_$1_$$"
}
# Process command-line options
. "${_Dbg_libdir}/init/opts.sh"
OPTLIND=1
_Dbg_parse_options "$@"
if [[ ! -d "$_Dbg_tmpdir" ]] && [[ ! -w "$_Dbg_tmpdir" ]] ; then
echo "${_Dbg_pname}: cannot write to temp directory $_Dbg_tmpdir." >&2
echo "${_Dbg_pname}: Use -T try directory location." >&2
exit 1
fi
# Save the initial working directory so we can reset it on a restart.
typeset -x _Dbg_init_cwd=$PWD
typeset -i _Dbg_running=1 # True we are not finished running the program
typeset -i _Dbg_brkpt_num=0 # If nonzero, the breakpoint number that we
# are currently stopped at.
# Sets whether or not to display command before executing it.
typeset _Dbg_set_trace_commands='off'
# Known normal IFS consisting of a space, tab and newline
typeset -x _Dbg_space_IFS=$' \t\r\n'
# Number of statements to run before entering the debugger. Is used
# intially to get out of sourced dbg-main.inc script and in top-level
# debugger script to not stop in remaining debugger statements before
# the sourcing the script to be debugged.
typeset -i _Dbg_step_ignore=1
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.