summaryrefslogtreecommitdiff
path: root/printHash.sh
diff options
context:
space:
mode:
authormssx86 <mss@tutanota.de>2021-07-01 20:14:46 +0300
committerwithmorten <morten.with@gmail.com>2021-07-05 22:40:30 +0200
commit37a43ebf45d5e58352b34113b1826b3afba4be67 (patch)
tree709257d0a4d4a59ce9a8f3252e0dc7d2478dba08 /printHash.sh
parentc5e896c4202e6518a31cf7edb5a4f9c8bfdb2dea (diff)
fix: printHash.sh; replace echo -n, check if $1 is set.
Diffstat (limited to 'printHash.sh')
-rwxr-xr-xprintHash.sh24
1 files changed, 13 insertions, 11 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
-
-> $1
-
-echo -n "#define GIT_SHA1 \"" > $1
-
-if (command -v "git" >/dev/null) then
-git rev-parse --short HEAD | tr -d '\n' >> $1
+#!/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
+
+ if (command -v "git" >/dev/null) then
+ git rev-parse --short HEAD | tr -d '\n' >> $1
+ fi
+
+ 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