testmark-bash

test-old-bash.sh

#!/bin/bash
## Sourcing under a bash older than 4.4 fails with one clear line.
## Uses the builds in BASH_VERSIONS_DIR (default /tmp/bash-versions), from the research's build-bash-versions.sh;
## each one that's missing is skipped with a note.
set -euo pipefail
cd "$(dirname "$0")"
# shellcheck source=tests/lib.sh
source ./lib.sh

for v in 3.2 4.3; do
	b=${BASH_VERSIONS_DIR:-/tmp/bash-versions}/bin/bash-$v
	if [ ! -x "$b" ]; then
		echo "SKIP  bash $v: no $b"
		continue
	fi
	got=$("$b" -c 'source "$1" 2>&1 || echo "rc=$?"' _ "$ROOT/lib/testmark.bash")
	expect_eq "bash $v refuses" "$got" "testmark: needs bash 4.4 or later; this is $("$b" -c 'echo "$BASH_VERSION"')"$'\n'"rc=1"
done

exit "$RESULT"

tests/test-old-bash.sh · 705 B · 29dc7c3cab