File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,11 @@ if [[ -z "${BASH_VERSINFO-}" ]] || (( BASH_VERSINFO[0] < 3 || (BASH_VERSINFO[0]
47
47
return 1
48
48
fi
49
49
50
+ # We do not enable bash-preexc in non-interactive shells (except in tests)
51
+ if [[ $- != * i* && ! ${__bp_inside_test-} ]]; then
52
+ return 0
53
+ fi
54
+
50
55
# Avoid duplicate inclusion
51
56
if [[ -n " ${bash_preexec_imported:- } " || -n " ${__bp_imported:- } " ]]; then
52
57
return 0
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bats
2
2
3
+ # This variable tells bash-preexec.sh that it is loaded for the testing
4
+ # purposes. bash-preexec.sh is intended to be used in interactive shell
5
+ # sessions, so it is disabled in non-interactive shells by default. However,
6
+ # it still needs to be loaded in non-interactive shells for the Bats tests,
7
+ __bp_inside_test=yes
8
+
3
9
setup () {
4
10
PROMPT_COMMAND=' ' # in case the invoking shell has set this
5
11
history -s fake command # preexec requires there be some history
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bats
2
2
3
+ # This variable tells bash-preexec.sh that it is loaded for the testing
4
+ # purposes. bash-preexec.sh is intended to be used in interactive shell
5
+ # sessions, so it is disabled in non-interactive shells by default. However,
6
+ # it still needs to be loaded in non-interactive shells for the Bats tests,
7
+ __bp_inside_test=yes
8
+
3
9
@test " should not import if it's already defined" {
4
10
bash_preexec_imported=" defined"
5
11
source " ${BATS_TEST_DIRNAME} /../bash-preexec.sh"
You can’t perform that action at this time.
0 commit comments