From f67d9bd752ba01d2ecdb2ac6ae697956b27b718b Mon Sep 17 00:00:00 2001 From: Joakim Roubert Date: Tue, 6 Dec 2022 10:34:06 +0100 Subject: [PATCH] GitVersion.sh: Make script simpler and more portable - No need to use bash for simple script, more portable with /bin/sh when the content is POSIX anyway - Use command instead of which and string comparison to see if git executable exists - Do not double quote static strings - Use contemporary $() instead of deprecated backtick syntax Signed-off-by: Joakim Roubert --- linux/GitVersion.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/linux/GitVersion.sh b/linux/GitVersion.sh index 8032e902..d6ccb335 100755 --- a/linux/GitVersion.sh +++ b/linux/GitVersion.sh @@ -1,9 +1,7 @@ -#!/bin/bash +#!/bin/sh #set -x -GIT=`which git` -if [ "x"${GIT} == "x" ]; then - echo "#define GIT_VERSION \"tarball\"" +if command -v git >/dev/null; then + echo "#define GIT_VERSION \"$(git describe --dirty)\"" else - GITVER=`git describe --dirty` - echo "#define GIT_VERSION " \"$GITVER\" + echo '#define GIT_VERSION "tarball"' fi