Add missing version compare function

This commit is contained in:
Jeremy Gardais 2023-01-30 17:33:55 +01:00
parent 76c54b4250
commit 07813d0011
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 25 additions and 0 deletions

View File

@ -167,6 +167,31 @@ ${RED}${local_command_available_cmd}${COLOR_DEBUG} is not available on this host
return "${return_command_available}" return "${return_command_available}"
} }
# }}} # }}}
is_version_greater_than() { # {{{
first_value="${1}"
value_to_compare="${2}"
## Return False by default
return_is_version_greater_than="1"
debug_message "is_version_greater_than \
Is first value (${first_value}) greater than the second value (${value_to_compare})."
if printf '%s\n' "${first_value}" "${value_to_compare}" | sort --check=quiet --version-sort; then
debug_message "is_version_greater_than ${first_value} <= ${value_to_compare} ."
return_is_version_greater_than="1"
else
debug_message "is_version_greater_than ${first_value} > ${value_to_compare} ."
return_is_version_greater_than="0"
fi
unset first_value
unset value_to_compare
return "${return_is_version_greater_than}"
}
# }}}
main() { # {{{ main() { # {{{