From de64bbe875fb0ff1dd8bdd0b2a33e713b344a98f Mon Sep 17 00:00:00 2001 From: mssx86 Date: Thu, 1 Jul 2021 20:14:46 +0300 Subject: [PATCH] fix: printHash.sh; replace echo -n, check if $1 is set. --- printHash.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/printHash.sh b/printHash.sh index e7d6f018..213d9353 100755 --- a/printHash.sh +++ b/printHash.sh @@ -1,12 +1,14 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh +if [ -z "${1}" ] + then + printf "%s\n" "Input the path to the file for writing the commit hash to." + else + printf "%s" "#define GIT_SHA1 \"" > $1 -> $1 + if (command -v "git" >/dev/null) then + git rev-parse --short HEAD | tr -d '\n' >> $1 + fi -echo -n "#define GIT_SHA1 \"" > $1 - -if (command -v "git" >/dev/null) then -git rev-parse --short HEAD | tr -d '\n' >> $1 + printf "%s\n" "\"" >> $1 + printf "%s\n" "const char* g_GIT_SHA1 = GIT_SHA1;" >> $1 fi - -echo "\"" >> $1 -echo "const char* g_GIT_SHA1 = GIT_SHA1;" >> $1 \ No newline at end of file