Browse Source

added small function to compare semantic versions

uses sort and head as external deps
Jaromil 3 years ago
parent
commit
f2785eca10
1 changed files with 6 additions and 0 deletions
  1. 6 0
      zuper

+ 6 - 0
zuper

@@ -531,6 +531,12 @@ s/      /%09/g
531 531
 '
532 532
 }
533 533
 
534
+# Check if a version number (semantic format) is greater than the other
535
+# returns 0 if the first argument is greater or equal than the second.
536
+function string.version_greatoreq version_greatoreq() {
537
+	[[ "$(printf '%s\n' "$@" | sort -rV | head -n 1)" = "$1" ]] && return 0
538
+	return 1
539
+}
534 540
 
535 541
 # }}} Strings
536 542