Don't load if old version already present (Fixes rcaloras/bash-preexec#146) (#150)

This commit is contained in:
Jim Winstead 2024-01-23 20:56:16 -08:00 committed by GitHub
parent fb23d474b3
commit f872f3fff2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -48,7 +48,7 @@ if [[ -z "${BASH_VERSINFO-}" ]] || (( BASH_VERSINFO[0] < 3 || (BASH_VERSINFO[0]
fi
# Avoid duplicate inclusion
if [[ -n "${bash_preexec_imported:-}" ]]; then
if [[ -n "${bash_preexec_imported:-}" || -n "${__bp_imported:-}" ]]; then
return 0
fi
bash_preexec_imported="defined"

View file

@ -6,6 +6,12 @@
[ -z $(type -t __bp_install) ]
}
@test "should not import if it's already defined (old guard, don't use elsewhere!)" {
__bp_imported="defined"
source "${BATS_TEST_DIRNAME}/../bash-preexec.sh"
[ -z $(type -t __bp_install) ]
}
@test "should import if not defined" {
unset bash_preexec_imported
source "${BATS_TEST_DIRNAME}/../bash-preexec.sh"