From 2e44b920c93ccc8b46bd950245045bc57288a839 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Fri, 22 Sep 2017 09:51:53 +0200 Subject: [PATCH] Add functionality to check the bash version Bats has know issues with old versions of bash < 4.1 as explained in issues #49 and #140. These issues create confusion because bats runs the tests without errors, but the results of the tests are wrong. This patchs adds the capability to check for the bash version and exit if it's not supported. --- libexec/bats | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libexec/bats b/libexec/bats index 71f392f..77d897d 100755 --- a/libexec/bats +++ b/libexec/bats @@ -1,6 +1,16 @@ #!/usr/bin/env bash set -e +check_bash_version() { + if [ ${BASH_VERSINFO[0]} -lt 4 ] ; then + echo "Bats has known issues with old versions of Bash" + echo "and doesn't work as expected, see issue #49 and #140" + echo "in https://github.com/sstephenson/bats/issues/" + echo "Please use Bash versions greater or equal to 4.1" + exit 1 + fi +} + version() { echo "Bats 0.4.0" } @@ -52,6 +62,7 @@ expand_path() { } || echo "$1" } +check_bash_version BATS_LIBEXEC="$(abs_dirname "$0")" export BATS_PREFIX="$(abs_dirname "$BATS_LIBEXEC")" export BATS_CWD="$(abs_dirname .)"