Skip to content
Open
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
4 changes: 2 additions & 2 deletions command/debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ _Dbg_do_debug() {

_Dbg_shell_new_shell_profile

typeset script_cmd=${@:-$_Dbg_bash_command}
typeset script_cmd=${@:--- $_Dbg_bash_command}

# We need to expand variables that might be in $script_cmd.
# set_Dbg_nested_debug_cmd is set up to to be eval'd below.
Expand All @@ -55,7 +55,7 @@ _Dbg_do_debug() {
set_Dbg_debug_cmd="typeset _Dbg_debug_cmd=\"$BASH --init-file ${_Dbg_shell_temp_profile} --debugger $script_cmd\"";
elif [[ $_Dbg_orig_0/// == *bashdb/// ]] ; then
# Running "bashdb", so prepend "bash bashdb .."
set_Dbg_debug_cmd="typeset _Dbg_debug_cmd=\"$BASH $_Dbg_orig_0 -q -L $_Dbg_libdir $script_cmd\"";
set_Dbg_debug_cmd="typeset _Dbg_debug_cmd=\"$BASH $_Dbg_orig_0 -q -L $_Dbg_libdir ${_Dbg_subdebug_args[@]} $script_cmd\"";
fi
eval "$_Dbg_resteglob"
eval $set_Dbg_debug_cmd
Expand Down
32 changes: 31 additions & 1 deletion init/opts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ eval "_Dbg_orig_script_args=(\"\$@\")"
# The following globals are set by _Dbg_parse_opts. Any values set are
# the default values.
typeset -xa _Dbg_script_args
typeset -xa _Dbg_subdebug_args;

# Use gdb-style annotate?
typeset -i _Dbg_set_annotate=0
Expand Down Expand Up @@ -190,7 +191,8 @@ _Dbg_parse_options() {
_Dbg_highlight_enabled=0
_Dbg_set_highlight='' ;;
init-file )
_Dbg_o_init_files+="$OPTLARG"
_Dbg_o_init_files+=("$OPTLARG") # XAX separate fix
_Dbg_subdebug_args+=(--init-file "$OPTLARG")
;;
L | library ) ;;
V | version )
Expand Down Expand Up @@ -265,6 +267,34 @@ welcome to change it and/or distribute copies of it under certain conditions.
unset _Dbg_o_annotate _Dbg_o_version _Dbg_o_quiet
_Dbg_script_args=("$@")

# Construct cli args to pass to sub-bashdb invocations
_Dbg_subdebug=( # <varname>:<cliarg>
_Dbg_o_annotate:-A=
_Dbg_set_basename:-B
#_Dbg_init_file:--init-file # Arrays are handled in getopts loop above
#--library is handled specially
#_Dbg_EXECUTION_STRING:--command= # Not passed to sub-bashrc's
_Dbg_o_nx:--no-init
_Dbg_set_style:--style=
_Dbg_tty:--tty=
_Dbg_tty_in:--tty_in=
_Dbg_tmpdir:--tempdir=
_Dbg_set_linetrace:--trace

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to add:

_Dbg_libdir:-L=

because, my initial bash invocation was:

/tmp/bashdb/bashdb -L /tmp/bashdb --tty /dev/tty --tty_in /dev/tty /tmp/somescript

Here is what I got initially without the above change (following the issue instructions):

$ git checkout HEAD
bash debugger, bashdb, release 5.2-1.2.0

Copyright 2002-2004, 2006-2012, 2014, 2016-2019, 2021, 2023-2024 Rocky Bernstein
This is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.

/tmp/bashdb/init/opts.sh: line 294: ((: /tmp/bashdb: syntax error: operand expected (error token is "/tmp/bashdb")
(/tmp/somescript:1):
1:	/tmp/otherscript
bashdb<0> 
bashdb: That's all, folks...

)
_Dbg_subdebug_args=()
local subarg subarg_var subarg_cli
for subarg in ${_Dbg_subdebug[@]} ; do
declare -n subarg_var=${subarg%:*}
subarg_cli=${subarg#*:}
if [[ "$subarg_cli" = *= ]] ; then
if [[ -n "${subarg_var}" ]] ; then
_Dbg_subdebug_args+=("${subarg_cli%=}" "${subarg_var}")
fi
elif (( subarg_var )) ; then
_Dbg_subdebug_args+=("${subarg_cli%}")
fi
done

if (( _Dbg_have_working_pygmentize )) && (( _Dbg_highlight_enabled )) && [[ -z "$_Dbg_set_highlight" ]] ; then
# Honor DARK_BG if already set. If not set, set it.
if [[ -z "$DARK_BG" ]] ; then
Expand Down
Loading