From 2e1d8be00804a7d6cdeaed8ef0e89724ae799ed8 Mon Sep 17 00:00:00 2001 From: Eric Hawicz Date: Sun, 28 Jun 2026 13:28:27 -0400 Subject: [PATCH] Collect selected cli args and pass them to sub-invocations of bashrc through the "debug" command. Fixes Issue #71 --- command/debug.sh | 4 ++-- init/opts.sh | 32 +++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/command/debug.sh b/command/debug.sh index 4be0102d..070a2eb4 100644 --- a/command/debug.sh +++ b/command/debug.sh @@ -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. @@ -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 diff --git a/init/opts.sh b/init/opts.sh index fdcdcc1a..e5ac1da8 100644 --- a/init/opts.sh +++ b/init/opts.sh @@ -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 @@ -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 ) @@ -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=( # : + _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 + ) + _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