Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.4: Fix more pollution with global variables, improve handling of paths with whitespace #47

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions bashdb-main.inc.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@ typeset _Dbg_release='@PACKAGE_VERSION@'
typeset _Dbg_bashdb_main='@DBGR_MAIN@'

# The short shell name. Helps keep code common in bash, zsh, and ksh debuggers.
typeset _Dbg_shell_name=${_Dbg_shell##*/} # Equivalent to basename(_Dbg_shell)
typeset _Dbg_shell_name="${_Dbg_shell##*/}" # Equivalent to basename(_Dbg_shell)

# Original $0. Note we can't set this in an include.
typeset _Dbg_orig_0=$0
typeset _Dbg_orig_0="$0"

# Equivalent to basename $0; the short program name
typeset _Dbg_pname=${0##*/}
typeset _Dbg_pname="${0##*/}"

## Stuff set by autoconf/configure ###
typeset prefix=@prefix@ # @PKGDATADIR@ often uses $prefix
typeset _Dbg_libdir=@PKGDATADIR@
# @PKGDATADIR@ often uses $prefix, _Dbg_libdir must be a global variable
_Dbg_assign_libdir() { typeset prefix="@prefix@"; _Dbg_libdir="@PKGDATADIR@"; }; _Dbg_assign_libdir
###

# We agonize a bit over _Dbg_libdir: the root directory for where
# debugger code is stored.
[[ -d $_Dbg_libdir ]] || _Dbg_libdir=${_Dbg_bashdb_main%/*} # dirname(_Dbg_bashdb_main)
[[ -d $_Dbg_libdir ]] || _Dbg_libdir='.'
[[ -d "$_Dbg_libdir" ]] || _Dbg_libdir="${_Dbg_bashdb_main%/*}" # dirname(_Dbg_bashdb_main)
[[ -d "$_Dbg_libdir" ]] || _Dbg_libdir='.'

typeset _Dbg_main="$_Dbg_libdir/dbg-main.sh"
if [[ ! -r $_Dbg_main ]] ; then
if [[ ! -r "$_Dbg_main" ]] ; then
echo "${_Dbg_pname}: Can't read debugger library file '${_Dbg_main}'."
echo "${_Dbg_pname}: Perhaps @PACKAGE@ is installed wrong (if its installed)." >&2
echo "${_Dbg_pname}: Try running @PACKAGE@ using -L (with a different directory)." >&2
Expand All @@ -57,6 +57,6 @@ if [[ ! -r $_Dbg_main ]] ; then
fi

# Pull in the rest of the debugger code.
. $_Dbg_main
. "$_Dbg_main"

trap '_Dbg_debug_trap_handler 0 "$BASH_COMMAND" "$@"' DEBUG
4 changes: 2 additions & 2 deletions bashdb.in
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ typeset _Dbg_orig_0=$0
typeset _Dbg_pname=${0##*/}

## Stuff set by autoconf/configure ###
typeset prefix=@prefix@ # @PKGDATADIR@ often uses $prefix
typeset _Dbg_libdir="@PKGDATADIR@"
# @PKGDATADIR@ often uses $prefix, _Dbg_libdir must be a global variable
_Dbg_assign_libdir() { typeset prefix="@prefix@"; _Dbg_libdir="@PKGDATADIR@"; }; _Dbg_assign_libdir
###

# We agonize a bit over _Dbg_libdir: the root directory for where
Expand Down
1 change: 1 addition & 0 deletions command/info_sub/variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ function _Dbg_info_variables_parse_options {

typeset -i _Dbg_rc=0
typeset OPTLIND=''
typeset opt
while getopts_long irxaAtp opt \
integer no_argument \
readonly no_argument \
Expand Down
3 changes: 2 additions & 1 deletion lib/filecache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ function _Dbg_readin {
if [[ -z "$filename" ]] || [[ "$filename" == "$_Dbg_bogus_file" ]] ; then
eval "${_Dbg_source_array_var}[0]=\"$Dbg_EXECUTION_STRING\""
else
fullname=$(_Dbg_resolve_expand_filename "$filename")
typeset fullname
fullname="$(_Dbg_resolve_expand_filename "$filename")"
if [[ -r "$fullname" ]] ; then
typeset -r progress_prefix="Reading $filename"
_Dbg_file2canonic["$filename"]="$fullname"
Expand Down