#!/usr/bin/env sh # check for minimum version being fulfilled # Argument $1 must be the target version # Argument $2 must be the program version to check for # # Versions must be stripped of any leading labels or 'v', 'version' prefix # and will only be checked for their numeric contents. # 1.0 2.13 5.1.25 are all valid version numbers. # # Can also be used to check the correct sorting of an arbitrary number of # versions, if invoked like: # version_at_least 1.0 2.0 2.2 3.13 # If versions are out of order will return false. # # Further reading: # https://unix.stackexchange.com/questions/285924/how-to-compare-a-programs-version-in-a-shell-script # https://stackoverflow.com/questions/4493205/unix-sort-of-version-numbers printf '%s\n' "$@" | sort -t. -n -k1,1 -k2,2 -k3,3 -k4,4 --check=quiet