From c92910b97c1a9291eebc3696580a7e4f7455c07c Mon Sep 17 00:00:00 2001 From: Michael Mendy Date: Mon, 21 Oct 2024 08:56:44 -0700 Subject: [PATCH] Making the conditions cleaner. The condition [[ "${tag_value:0:1}" == "v" ]] is equivalent to [[ ${last_half::1} == "v" ]], both checking if the first character is "v". --- .version.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.version.sh b/.version.sh index 14adccbf..46d1abf5 100755 --- a/.version.sh +++ b/.version.sh @@ -1,7 +1,10 @@ #!/usr/bin/env bash + read -r firstline < .VERSION -last_half="${firstline##*tag: }" -if [[ ${last_half::1} == "v" ]]; then - version_string="${last_half%%[,)]*}" +tag_value="${firstline##*tag: }" + +if [[ "${tag_value:0:1}" == "v" ]]; then + version_string="${tag_value%%[,)]*}" fi + echo "${version_string:-v0.0.0}"