diff --git a/test/lib/library.sh b/test/lib/library.sh index df683c6d..a2973a06 100644 --- a/test/lib/library.sh +++ b/test/lib/library.sh @@ -24,3 +24,24 @@ echo_array() { local IFS=$'\n' 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() + diff --git a/test/lib/unit.exp b/test/lib/unit.exp index 68bed0bf..dd09f674 100644 --- a/test/lib/unit.exp +++ b/test/lib/unit.exp @@ -18,6 +18,12 @@ proc unit_start {} { assert_bash_exec {} "bash --rcfile config/bashrc" assert_bash_exec {BASH_COMPLETION_DIR=$(cd ..; pwd)/contrib} 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} }; # unit_start()