gdritter repos GRUtils / efe8115
Added new-cabal-exec script Getty Ritter 8 years ago
1 changed file(s) with 19 addition(s) and 0 deletion(s). Collapse all Expand all
1 #!/bin/bash -e
2
3 if [ $# -gt 0 ]; then
4 NAME="$1"
5 shift
6 else
7 NAME="$(basename $(pwd))"
8 fi
9
10 VERSION="$(cat *.cabal | grep -e '^version' | grep -o -e '[0-9.]*')"
11 PROGRAM="$(find dist-newstyle -type f -executable -name "$NAME" | grep -e "${VERSION}" | head -n 1)"
12
13
14 if [ ! "${PROGRAM}" = "" ]; then
15 exec "${PROGRAM}" $@
16 else
17 echo "cannot find executable: ${NAME}-${VERSION}" >&2
18 exit 99
19 fi