diff mbox series

[03/18] version-gen: refactor default version

Message ID 20230414121841.373980-4-felipe.contreras@gmail.com (mailing list archive)
State Superseded
Headers show
Series [01/18] version-gen: reorganize | expand

Commit Message

Felipe Contreras April 14, 2023, 12:18 p.m. UTC
It's not clear how `cat version` might fail, but either way if VN is
empty (or unset), assign the default value.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 GIT-VERSION-GEN | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 6dd7683ee7..0d00fa3d9a 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -25,14 +25,14 @@  describe () {
 # then try `git describe`, then default.
 if test -f version
 then
-	VN=$(cat version) || VN="$DEF_VER"
+	VN=$(cat version)
 elif test -d "${GIT_DIR:-.git}" -o -f .git && describe
 then
 	VN=$(echo "$VN" | sed -e 's/-/./g')
-else
-	VN="$DEF_VER"
 fi
 
+: "${VN:=$DEF_VER}"
+
 VN=$(expr "$VN" : 'v*\(.*\)')
 
 if test -r $GVF