Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bash-preexec.sh
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading