3 # Comparison expressions for semantic versions.
4 # only supports semver standard MAJOR.MINOR.PATCH syntax;
5 # pre-release or build-metadata extensions have undefined behavior.
11 echo "Comparison expressions for semantic versions."
13 echo "usage: vercmp VERSION_A OPERATOR VERSION_B"
17 echo " lt - Less than"
18 echo " lteq - Less than or equal to"
20 echo " gteq - Grater than or equal to"
21 echo " gt - Greater than"
25 if [ "$#" -ne 3 ]; then
34 if [ "$LEFT" = "$RIGHT" ]; then
37 SORTED
=($
(for VER
in "$LEFT" "$RIGHT"; do echo "$VER"; done |
sort -V))
38 if [ "${SORTED[0]}" = "$LEFT" ]; then
49 if [ "$COMPARISON" -eq -1 ]; then
55 if [ "$COMPARISON" -lt 1 ]; then
61 if [ "$COMPARISON" -eq 0 ]; then
67 if [ "$COMPARISON" -gt -1 ]; then
73 if [ "$COMPARISON" -eq 1 ]; then
84 VERCMP_QUIET
="${VERCMP_QUIET:-false}"
85 if [ ! "$VERCMP_QUIET" = "true" ]; then
89 if [ "$OUTCOME" = "true" ]; then