diff --git a/tests.sh b/tests.sh index 625af9a..6c86f41 100755 --- a/tests.sh +++ b/tests.sh @@ -24,12 +24,12 @@ readonly G_SHELLCHECK_VERSION="0.6.0" f_compare_version(){ local required_v="$1" local getted_v="$2" - + # First: check if equal if [ "$required_v" = "$getted_v" ]; then return 0; fi - + # Second: check if greater or lesser local test_v test_v="$(printf "%s\n%s" "$required_v" "$getted_v" | sort -V | head -n 1)" @@ -44,14 +44,18 @@ f_compare_version(){ f_test_nano_version() { local version - version="$(nano --version | cut -d ' ' -f 4)" + version="$(nano --version | cut -d ' ' -f 5 | head -n 1)" + echo $G_NANO_VERSION + echo $version f_compare_version "$G_NANO_VERSION" "$version" return $? } f_test_shellcheck_version() { local version - version="$(nano --version | cut -d ' ' -f 8)" + version="$(shellcheck --version | cut -d ' ' -f 2 | head -n 2 | tail -n 1)" + echo $G_SHELLCHECK_VERSION + echo $version f_compare_version "$G_SHELLCHECK_VERSION" "$version" return $? } @@ -60,8 +64,8 @@ printf "=================\n" printf "TESTS\n" printf "=================\n" f_test_nano_version -printf "Nano Version ok? %s\n" "$?" +printf "Nano Version ok? %s (1 = ok)\n" "$?" f_test_shellcheck_version -printf "Shellcheck Version ok? %s\n" "$?" +printf "Shellcheck Version ok? %s (1 = ok)\n" "$?" # ....shellcheck -f diff *.sh | git apply | git commit -a -m "Shellcheck fast corrections" shellcheck -- *.sh