Skip to content

Commit

Permalink
Use command to execute sed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jparise committed Jan 13, 2025
1 parent e8e9024 commit 5aa611a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bash-preexec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 5aa611a

Please sign in to comment.