Browse Source

Added new-cabal-exec script

Getty Ritter 7 years ago
parent
commit
efe8115841
1 changed files with 19 additions and 0 deletions
  1. 19 0
      scripts/new-cabal-exec

+ 19 - 0
scripts/new-cabal-exec

@@ -0,0 +1,19 @@
+#!/bin/bash -e
+
+if [ $# -gt 0 ]; then
+    NAME="$1"
+	shift
+else
+    NAME="$(basename $(pwd))"
+fi
+
+VERSION="$(cat *.cabal | grep -e '^version' | grep -o -e '[0-9.]*')"
+PROGRAM="$(find dist-newstyle -type f -executable -name "$NAME" | grep -e "${VERSION}" | head -n 1)"
+
+
+if [ ! "${PROGRAM}" = "" ]; then
+	exec "${PROGRAM}" $@
+else
+	echo "cannot find executable: ${NAME}-${VERSION}" >&2
+	exit 99
+fi