Skip to content

Commit

Permalink
! fix versionLessThan
Browse files Browse the repository at this point in the history
  • Loading branch information
oldratlee committed Jan 11, 2021
1 parent 1ffd30b commit 75475c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions scripts/bump-cola-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ set -eEuo pipefail
cd "$(dirname "$(readlink -f "$0")")"

source common.sh
source common_build.sh

# shellcheck disable=SC2154
[ $# -ne 1 ] && die "need 1 argument for version!$nl${nl}usage:$nl $0 4.x.y"

[ $# -ne 1 ] && die "need only 1 argument for version!$nl${nl}usage:$nl $0 4.x.y"
readonly bump_version="$1"

source common_build.sh

(
headInfo "bump cola version of cola-components to $bump_version"
cd ../cola-components/
Expand Down
4 changes: 2 additions & 2 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ headInfo() {
# How to compare a program's version in a shell script?
# https://unix.stackexchange.com/questions/285924
versionLessThan() {
(($# == 2)) || die "versionLessThan must 2 arguments"
(($# == 2)) || die "${FUNCNAME[0]} need only 2 arguments, actual arguments: $*"
local ver=$1
local destVer=$2

[ "$ver" = "$destVer" ] && return 0
[ "$ver" = "$destVer" ] && return 1

[ "$(printf '%s\n' "$ver" "$destVer" | sort -V | head -n1)" = "$ver" ]
}
Expand Down

0 comments on commit 75475c7

Please sign in to comment.