Created
August 29, 2019 19:29
-
-
Save mattolenik/a4eeeb9291f7274576e321365d769986 to your computer and use it in GitHub Desktop.
bash function for ensuring bash version meets a certain minimum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensures the shell meets some minimum version, useful when using bash features introduced after a certain release | |
check_version() { | |
local reqMajor="$1" | |
local reqMinor="$2" | |
local major minor | |
IFS=. read -r major minor _ <<< "$BASH_VERSION" | |
if (( major < reqMajor )) || (( major == reqMajor && minor < reqMinor)); then | |
echo "Bash version $reqMajor.$reqMinor or greater required, found $major.$minor" >&2 | |
return 1 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment