Skip to content

Commit

Permalink
Don't load if old version already present (Fixes #146) (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimwins committed Jan 24, 2024
1 parent fb23d47 commit f872f3f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bash-preexec.sh
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions test/include-test.bats
Expand Up @@ -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"
Expand Down

0 comments on commit f872f3f

Please sign in to comment.