From 855a806a5b30498811d92d2ced9eb9e434e61270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Wed, 24 Mar 2021 18:20:53 +0100 Subject: [PATCH] Rewrite get_version.sh to make it work on macOS --- scripts/get_version.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/get_version.sh b/scripts/get_version.sh index 7691451d9..e5f8615e7 100755 --- a/scripts/get_version.sh +++ b/scripts/get_version.sh @@ -26,6 +26,11 @@ # (c) 2017 solidity contributors. #------------------------------------------------------------------------------ -set -e +set -eu -grep -oP "PROJECT_VERSION \"?\K[0-9.]+(?=\")?" "$(dirname "$0")/../CMakeLists.txt" +version=$(sed -n -E -e 's/^\s*set\(PROJECT_VERSION "([0-9.]+)"\)\s*$/\1/p' "$(dirname "$0")/../CMakeLists.txt") + +# Sanity check. Sed does not fail if it does not find a match or finds more than one. +[[ $version =~ ^[0-9.]+$ ]] || { echo "Failed to find version in CMakeLists.txt"; exit 1; } + +echo "$version"