From 75475c7786e7216598f15b9fc39fde4666298d1f Mon Sep 17 00:00:00 2001 From: Jerry Lee Date: Mon, 11 Jan 2021 11:49:21 +0800 Subject: [PATCH] ! fix versionLessThan --- scripts/bump-cola-version.sh | 6 ++---- scripts/common.sh | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/bump-cola-version.sh b/scripts/bump-cola-version.sh index 7f5ec5d5d..54b510eb4 100755 --- a/scripts/bump-cola-version.sh +++ b/scripts/bump-cola-version.sh @@ -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/ diff --git a/scripts/common.sh b/scripts/common.sh index f335943cf..e6c74d135 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -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" ] }