Perform syntax checking with all available bashes

Add tests to help catch bash4-isms and ensure syntax is checked with
 all bashes on PATH in a given system.
This commit is contained in:
Izaak Beekman 2017-02-10 14:33:29 -05:00
parent 986191210a
commit 2d5506cb36
No known key found for this signature in database
GPG Key ID: A93CE70D8021BD0F

View File

@ -193,7 +193,41 @@ done <<< "$(find "${__dir}/scenario" -type f -iname 'run.sh')"
[[ "${1:-}" ]] && exit 0
# finally do some shellcheck linting
# Ensure correct syntax with all available bashes
if bashes=($(which -a bash 2> /dev/null )); then
for bash in "${bashes[@]}"; do
# shellcheck disable=SC2016
echo "==> ${bash} -n $(${bash} -c 'echo "(${BASH_VERSION})"')"
pushd "${__root}" > /dev/null
failed="false"
while IFS=$'\n' read -r file; do
[[ "${file}" =~ ^\./node_modules/ ]] && continue
[[ "${file}" =~ ^\./website/\.lanyon/ ]] && continue
echo -n " ${file}.. "
if ! "${bash}" -n "${file}" 2>> "${__accptstTmpDir}/${bash//\//.}.err"; then
echo "✗"
failed="true"
continue
fi
echo "✓"
done <<< "$(find . -type f -iname '*.sh')"
popd > /dev/null
if [[ "${failed}" = "true" ]]; then
cat "${__accptstTmpDir}/${bash//\//.}.err"
exit 1
fi
done
fi
# do some shellcheck linting
if [[ "$(command -v shellcheck)" ]]; then
echo "==> Shellcheck"
pushd "${__root}" > /dev/null