bash-completion/test/lib/library.sh
Freddy Vulto c6a8b856de (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.
2009-09-16 22:05:23 +02:00

48 lines
1.2 KiB
Bash

# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 noet filetype=sh
#
# Bash library for bash-completion DejaGnu testsuite
# Diff environment files to detect if environment is unmodified
# @param $1 File 1
# @param $2 File 2
# @param $1 Additional sed script
diff_env() {
diff "$1" "$2" | sed -e "
/^[0-9,]\+[acd]/d # Remove diff line indicators
/---/d # Remove diff block separators
/[<>] _=/d # Remove underscore variable
/[<>] PPID=/d # Remove PPID bash variable
$3"
} # diff_env()
# Output array elements, sorted and separated by newline
# @param $1 Name of array variable to process
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()