diff --git a/src/base/get_version.sh b/src/base/get_version.sh index 4c1e8059059..94efd41b631 100755 --- a/src/base/get_version.sh +++ b/src/base/get_version.sh @@ -39,15 +39,10 @@ cd "$(dirname ${BASH_SOURCE[0]})" # Read the partial version number specified in the first line of src/.version. version=$(head -1 ../.version) -# Empty version number is not allowed. -if [ -z "$version" ]; then - version="?" -fi - if [ -e ../.short_version ]; then echo "$0: File src/.short_version exists." echo "$0: Stopping the construction of full version number from git history." -elif [[ $version != +([0-9]).+([0-9]) ]]; then +elif ! [[ $version =~ ^[0-9][0-9]*.[0-9][0-9]*$ ]]; then echo "$0: The version number \"$version\" specified in src/.version is not" \ "in MAJOR.MINOR format." echo "$0: Stopping the construction of full version number from git history." @@ -76,6 +71,11 @@ else version="$version-${head_commit_short}" fi +# Empty version number is not allowed. +if [ -z "$version" ]; then + version="?" +fi + # Write version info to a temporary file. temp=$(mktemp) trap 'rm -f "$temp"' EXIT