summaryrefslogtreecommitdiff
path: root/scripts/hash.sh
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2018-02-15 21:24:24 -0800
committerMichael Forney <mforney@mforney.org>2018-02-16 02:52:34 -0800
commit741d25282274e59c785b9cbee23cefff3d2721a2 (patch)
treeb7eaf7402cb1a61c220a3f0eecc3bc63cec14eaa /scripts/hash.sh
parent83d57181d1565d9c12b7d2467be9008d2b6edeab (diff)
Port build scripts to POSIX shell
Since we are now using Lua to generate ninja files, use of rc in build scripts seems unnecessary and adds an additional bootstrap dependency. None of them are too fancy, so just port to POSIX sh instead.
Diffstat (limited to 'scripts/hash.sh')
-rw-r--r--scripts/hash.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/scripts/hash.sh b/scripts/hash.sh
new file mode 100644
index 00000000..15861d27
--- /dev/null
+++ b/scripts/hash.sh
@@ -0,0 +1,18 @@
+set -e
+
+repo=$1
+mode=$2
+name=$3
+shift 3
+
+case "$mode" in
+12????)
+ hash=$(printf %s "$1" | git -C "$repo" hash-object -w --stdin) ;;
+10????)
+ hash=$(git -C "$repo" hash-object -w --stdin <"$1") ;;
+*)
+ echo "invalid mode: $mode"
+ exit 1
+esac
+
+printf '%s %s\t%s\n' "$mode" "$hash" "$name"