(testsuite) set +o history for bash < 3.2.41

Bash < 3.2.41 has a bug where 'history' disappears from SHELLOPTS
whenever a shopt setting is sourced or eval'ed.  Disabling 'history'
makes it not show in tests "Environment should not be modified"
for bash < 3.2.41.
Added helper function `is_bash_version_minimal()' to
test/lib/library.sh.
This commit is contained in:
Freddy Vulto 2009-09-16 22:05:23 +02:00
parent 8eaf5a1c2a
commit c6a8b856de
2 changed files with 27 additions and 0 deletions

View File

@ -24,3 +24,24 @@ echo_array() {
local IFS=$'\n' local IFS=$'\n'
eval echo \"\${$1[*]}\" | sort eval echo \"\${$1[*]}\" | sort
} }
# Check if current bash version meets specified minimum
# @param $1 (integer) Major version number
# @param $2 (integer) Minor version number
# @param $3 (integer) Patch level
# @return 0 if success, > 0 if not
is_bash_version_minimal() {
[[ (
${BASH_VERSINFO[0]} -gt $1
) || (
${BASH_VERSINFO[0]} -eq $1 &&
${BASH_VERSINFO[1]} -gt $2
) || (
${BASH_VERSINFO[0]} -eq $1 &&
${BASH_VERSINFO[1]} -eq $2 &&
${BASH_VERSINFO[2]} -ge $3
)
]]
} # is_bash_version_minimal()

View File

@ -18,6 +18,12 @@ proc unit_start {} {
assert_bash_exec {} "bash --rcfile config/bashrc" assert_bash_exec {} "bash --rcfile config/bashrc"
assert_bash_exec {BASH_COMPLETION_DIR=$(cd ..; pwd)/contrib} assert_bash_exec {BASH_COMPLETION_DIR=$(cd ..; pwd)/contrib}
assert_bash_exec {BASH_COMPLETION=$(cd ..; pwd)/bash_completion} assert_bash_exec {BASH_COMPLETION=$(cd ..; pwd)/bash_completion}
# Bash < 3.2.41 has a bug where 'history' disappears from SHELLOPTS
# whenever a shopt setting is sourced or eval'ed. Disabling 'history'
# makes it not show in tests "Environment should not be modified"
# for bash < 3.2.41.
# -- FVu, Tue Sep 15 22:52:00 CEST 2009
assert_bash_exec {is_bash_version_minimal 3 2 41 || set +o history}
assert_bash_exec {source $BASH_COMPLETION} assert_bash_exec {source $BASH_COMPLETION}
}; # unit_start() }; # unit_start()