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@xxxxxxxxx> --- GIT-VERSION-GEN | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 -- 2.40.0+fc1