@@ -60,10 +60,14 @@ __bp_inside_precmd=0
60
60
__bp_inside_preexec=0
61
61
62
62
# 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} "
64
68
65
69
# 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 "$_"'
67
71
68
72
# Fails if any of the given variables are readonly
69
73
# Reference https://stackoverflow.com/a/4441178
@@ -146,10 +150,10 @@ __bp_precmd_invoke_cmd() {
146
150
return
147
151
fi
148
152
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 "
150
154
}
151
155
152
- __bp_invoke_precmd_functions () {
156
+ bash_preexec_invoke_precmd_functions () {
153
157
local __lastexit=$1 __lastarg=$2
154
158
# Invoke every function defined in our function array.
155
159
local precmd_function
@@ -252,7 +256,7 @@ __bp_preexec_invoke_exec() {
252
256
fi
253
257
254
258
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 "
256
260
257
261
# Restore the last argument of the last executed command, and set the return
258
262
# value of the DEBUG trap to be the return code of the last preexec function
@@ -266,7 +270,7 @@ __bp_preexec_invoke_exec() {
266
270
# This function invokes every function defined in our function array. This
267
271
# function assigns the last error exit status to the variable
268
272
# `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 () {
270
274
local __lastexit=$1 __lastarg=$2 __this_command=$3
271
275
local preexec_function
272
276
local preexec_function_ret_value
@@ -293,7 +297,7 @@ __bp_install() {
293
297
return 1;
294
298
fi
295
299
296
- trap " $__bp_trapdebug_string " DEBUG
300
+ trap " $bash_preexec_trapdebug_string " DEBUG
297
301
298
302
# Preserve any prior DEBUG trap as a preexec function
299
303
local prior_trap=$( sed " s/[^']*'\(.*\)'[^']*/\1/" <<< " ${__bp_trap_string:-}" )
@@ -322,8 +326,8 @@ __bp_install() {
322
326
local existing_prompt_command
323
327
# Remove setting our trap install string and sanitize the existing prompt command string
324
328
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 } "
327
331
__bp_sanitize_string existing_prompt_command " $existing_prompt_command "
328
332
329
333
# Install our hooks in PROMPT_COMMAND to allow our trap to know when we've
@@ -360,14 +364,14 @@ __bp_install_after_session_init() {
360
364
if [[ -n " $sanitized_prompt_command " ]]; then
361
365
PROMPT_COMMAND=${sanitized_prompt_command} $' \n '
362
366
fi ;
363
- PROMPT_COMMAND+=${__bp_install_string }
367
+ PROMPT_COMMAND+=${bash_preexec_install_string }
364
368
}
365
369
366
- __bp_uninstall () {
370
+ bash_preexec_uninstall () {
367
371
# 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 } "
371
375
fi
372
376
373
377
# Remove precmd hook from PROMPT_COMMAND
@@ -377,7 +381,7 @@ __bp_uninstall() {
377
381
378
382
# Remove preexec hook in the DEBUG trap
379
383
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
381
385
if [[ ${__bp_trap_string-} ]]; then
382
386
eval -- " $__bp_trap_string "
383
387
else
0 commit comments