new-cabal-exec 397 B

12345678910111213141516171819
  1. #!/bin/bash -e
  2. if [ $# -gt 0 ]; then
  3. NAME="$1"
  4. shift
  5. else
  6. NAME="$(basename $(pwd))"
  7. fi
  8. VERSION="$(cat *.cabal | grep -e '^version' | grep -o -e '[0-9.]*')"
  9. PROGRAM="$(find dist-newstyle -type f -executable -name "$NAME" | grep -e "${VERSION}" | head -n 1)"
  10. if [ ! "${PROGRAM}" = "" ]; then
  11. exec "${PROGRAM}" $@
  12. else
  13. echo "cannot find executable: ${NAME}-${VERSION}" >&2
  14. exit 99
  15. fi