diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-01-22 19:35:21 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-01-22 19:39:06 +0300 |
commit | abce4833a64f9dd18a7b90071e9772bc354bd3a6 (patch) | |
tree | 64ce484bc6d3c5b08d37245ad0144f48fee88378 /build_files | |
parent | fde6151641a8bb62029040e1a84775de3b5bd333 (diff) |
install_deps.sh: strip trailing punctuation from version numbers
Encountered this issue when enabling more libraries.
Diffstat (limited to 'build_files')
-rwxr-xr-x | build_files/build_environment/install_deps.sh | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index 33572ddb183..bc9ee802810 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -993,18 +993,21 @@ download() { fi } -# Remove suffix such as '1.3_RC2', keeping only '1.3'. -# Needed for numeric comparisons. version_sanitize() { - echo "$(sed -r 's/^([^_]+).*/\1/' <<< \"$1\")" + # Remove suffix such as '1.3_RC2', keeping only '1.3'. + # Needed for numeric comparisons. + local val=$(sed -r 's/^([^_]+).*/\1/' <<< "$1") + # Remove trailing punctuation such as '1.0.', keeping only '1.0'. + val=$(sed -r 's/[[:punct:]]*$//g' <<< "$val") + echo $val } # Return 0 if $1 = $2 (i.e. 1.01.0 = 1.1, but 1.1.1 != 1.1), else 1. # $1 and $2 should be version numbers made of numbers only. version_eq() { - local IFS='.' local VER_1=$(version_sanitize "$1") local VER_2=$(version_sanitize "$2") + local IFS='.' # Split both version numbers into their numeric elements. arr1=( $VER_1 ) @@ -1069,9 +1072,9 @@ version_ge_lt() { # $1 and $2 should be version numbers made of numbers only. # $1 should be at least as long as $2! version_match() { - local IFS='.' local VER_1=$(version_sanitize "$1") local VER_2=$(version_sanitize "$2") + local IFS='.' # Split both version numbers into their numeric elements. arr1=( $VER_1 ) |