@@ -60,10 +60,14 @@ __bp_inside_precmd=0
6060__bp_inside_preexec=0
6161
6262# Initial PROMPT_COMMAND string that is removed from PROMPT_COMMAND post __bp_install
63- __bp_install_string=$' __bp_trap_string="$(trap -p DEBUG)"\n trap - DEBUG\n __bp_install'
63+ bash_preexec_install_string=$' __bp_trap_string="$(trap -p DEBUG)"\n trap - DEBUG\n __bp_install'
64+
65+ # WARNING: This variable is no longer used and should not be relied upon.
66+ # Use ${bash_preexec_install_string} instead.
67+ __bp_install_string=" ${bash_preexec_install_string} "
6468
6569# The command string that is registered to the DEBUG trap.
66- __bp_trapdebug_string =' __bp_preexec_invoke_exec "$_"'
70+ bash_preexec_trapdebug_string =' __bp_preexec_invoke_exec "$_"'
6771
6872# Fails if any of the given variables are readonly
6973# Reference https://stackoverflow.com/a/4441178
@@ -146,10 +150,10 @@ __bp_precmd_invoke_cmd() {
146150 return
147151 fi
148152 local __bp_inside_precmd=1
149- __bp_invoke_precmd_functions " $__bp_last_ret_value " " $__bp_last_argument_prev_command "
153+ bash_preexec_invoke_precmd_functions " $__bp_last_ret_value " " $__bp_last_argument_prev_command "
150154}
151155
152- __bp_invoke_precmd_functions () {
156+ bash_preexec_invoke_precmd_functions () {
153157 local __lastexit=$1 __lastarg=$2
154158 # Invoke every function defined in our function array.
155159 local precmd_function
@@ -252,7 +256,7 @@ __bp_preexec_invoke_exec() {
252256 fi
253257
254258 local preexec_ret_value
255- __bp_invoke_preexec_functions " ${__bp_last_ret_value:- } " " $__bp_last_argument_prev_command " " $this_command "
259+ bash_preexec_invoke_preexec_functions " ${__bp_last_ret_value:- } " " $__bp_last_argument_prev_command " " $this_command "
256260
257261 # Restore the last argument of the last executed command, and set the return
258262 # value of the DEBUG trap to be the return code of the last preexec function
@@ -266,7 +270,7 @@ __bp_preexec_invoke_exec() {
266270# This function invokes every function defined in our function array. This
267271# function assigns the last error exit status to the variable
268272# `preexec_ret_value`. If there is no error, preexec_ret_value is set to `0`.
269- __bp_invoke_preexec_functions () {
273+ bash_preexec_invoke_preexec_functions () {
270274 local __lastexit=$1 __lastarg=$2 __this_command=$3
271275 local preexec_function
272276 local preexec_function_ret_value
@@ -293,7 +297,7 @@ __bp_install() {
293297 return 1;
294298 fi
295299
296- trap " $__bp_trapdebug_string " DEBUG
300+ trap " $bash_preexec_trapdebug_string " DEBUG
297301
298302 # Preserve any prior DEBUG trap as a preexec function
299303 local prior_trap=$( sed " s/[^']*'\(.*\)'[^']*/\1/" <<< " ${__bp_trap_string:-}" )
@@ -322,8 +326,8 @@ __bp_install() {
322326 local existing_prompt_command
323327 # Remove setting our trap install string and sanitize the existing prompt command string
324328 existing_prompt_command=" ${PROMPT_COMMAND:- } "
325- existing_prompt_command=" ${existing_prompt_command// $__bp_install_string [;$'\n']} " # Edge case of appending to PROMPT_COMMAND
326- existing_prompt_command=" ${existing_prompt_command// $__bp_install_string } "
329+ existing_prompt_command=" ${existing_prompt_command// $bash_preexec_install_string [;$'\n']} " # Edge case of appending to PROMPT_COMMAND
330+ existing_prompt_command=" ${existing_prompt_command// $bash_preexec_install_string } "
327331 __bp_sanitize_string existing_prompt_command " $existing_prompt_command "
328332
329333 # Install our hooks in PROMPT_COMMAND to allow our trap to know when we've
@@ -360,14 +364,14 @@ __bp_install_after_session_init() {
360364 if [[ -n " $sanitized_prompt_command " ]]; then
361365 PROMPT_COMMAND=${sanitized_prompt_command} $' \n '
362366 fi ;
363- PROMPT_COMMAND+=${__bp_install_string }
367+ PROMPT_COMMAND+=${bash_preexec_install_string }
364368}
365369
366- __bp_uninstall () {
370+ bash_preexec_uninstall () {
367371 # Remove __bp_install hook from PROMPT_COMMAND
368- if [[ ${PROMPT_COMMAND-} == * " $__bp_install_string " * ]]; then
369- PROMPT_COMMAND=" ${PROMPT_COMMAND// $__bp_install_string [;$'\n']} " # Edge case of appending to PROMPT_COMMAND
370- PROMPT_COMMAND=" ${PROMPT_COMMAND// $__bp_install_string } "
372+ if [[ ${PROMPT_COMMAND-} == * " $bash_preexec_install_string " * ]]; then
373+ PROMPT_COMMAND=" ${PROMPT_COMMAND// $bash_preexec_install_string [;$'\n']} " # Edge case of appending to PROMPT_COMMAND
374+ PROMPT_COMMAND=" ${PROMPT_COMMAND// $bash_preexec_install_string } "
371375 fi
372376
373377 # Remove precmd hook from PROMPT_COMMAND
@@ -377,7 +381,7 @@ __bp_uninstall() {
377381
378382 # Remove preexec hook in the DEBUG trap
379383 local q=" '" Q=" '\''"
380- if [[ $( trap -p DEBUG) == " trap -- '${__bp_trapdebug_string // $q / $Q } ' DEBUG" ]]; then
384+ if [[ $( trap -p DEBUG) == " trap -- '${bash_preexec_trapdebug_string // $q / $Q } ' DEBUG" ]]; then
381385 if [[ ${__bp_trap_string-} ]]; then
382386 eval -- " $__bp_trap_string "
383387 else
0 commit comments