Correct versions

This commit is contained in:
Tiago Almeida 2019-12-27 15:11:42 +00:00
parent adcdecee6c
commit 5d5521c048

View File

@ -24,12 +24,12 @@ readonly G_SHELLCHECK_VERSION="0.6.0"
f_compare_version(){ f_compare_version(){
local required_v="$1" local required_v="$1"
local getted_v="$2" local getted_v="$2"
# First: check if equal # First: check if equal
if [ "$required_v" = "$getted_v" ]; then if [ "$required_v" = "$getted_v" ]; then
return 0; return 0;
fi fi
# Second: check if greater or lesser # Second: check if greater or lesser
local test_v local test_v
test_v="$(printf "%s\n%s" "$required_v" "$getted_v" | sort -V | head -n 1)" 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() { f_test_nano_version() {
local 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" f_compare_version "$G_NANO_VERSION" "$version"
return $? return $?
} }
f_test_shellcheck_version() { f_test_shellcheck_version() {
local 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" f_compare_version "$G_SHELLCHECK_VERSION" "$version"
return $? return $?
} }
@ -60,8 +64,8 @@ printf "=================\n"
printf "TESTS\n" printf "TESTS\n"
printf "=================\n" printf "=================\n"
f_test_nano_version f_test_nano_version
printf "Nano Version ok? %s\n" "$?" printf "Nano Version ok? %s (1 = ok)\n" "$?"
f_test_shellcheck_version 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 -f diff *.sh | git apply | git commit -a -m "Shellcheck fast corrections"
shellcheck -- *.sh shellcheck -- *.sh