From 5aa611a5eb6676a6f129497cc2d5b92041cda14b Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Mon, 13 Jan 2025 08:57:40 -0500 Subject: [PATCH] Use `command` to execute `sed` We want our execution environment to be a predictable as possible. Similar to how we use `builtin` to ensure we're running the shell's builtin function (and not a redefinition), use `command` to ensure we're running `sed` and not a shell function or alias. --- bash-preexec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bash-preexec.sh b/bash-preexec.sh index b998944..c81fb53 100644 --- a/bash-preexec.sh +++ b/bash-preexec.sh @@ -300,7 +300,7 @@ __bp_install() { local prior_trap # we can't easily do this with variable expansion. Leaving as sed command. # shellcheck disable=SC2001 - prior_trap=$(sed "s/[^']*'\(.*\)'[^']*/\1/" <<<"${__bp_trap_string:-}") + prior_trap=$(builtin command sed "s/[^']*'\(.*\)'[^']*/\1/" <<<"${__bp_trap_string:-}") unset __bp_trap_string if [[ -n "$prior_trap" ]]; then eval '__bp_original_debug_trap() {