#!/bin/bash DEBUG=no TOP=$(cd $(dirname ${BASH_SOURCE[0]})/.. > /dev/null && pwd -P) dist=$(stack $HTF_TRAVIS_STACK_ARGS path --dist-dir 2> /dev/null) find=find if [ "$(uname)" == "Darwin" ]; then find=gfind fi function find_bin() { local d="$TOP/$dist" if [ ! -d "$d" ]; then d="$(dirname $d)" fi bin=$($find "$d" -name htfpp -type f -executable -printf "%T+\t%p\n" | sort -r | head -1 | gawk '{print $2}') } find_bin if [ "$DEBUG" == "yes" ]; then echo "TOP=$TOP" >&2 echo "dist=$dist" >&2 echo "bin=$bin" >&2 fi if [ -z "$bin" ]; then echo "No executable named htfpp found in $TOP/$dist. Aborting!" >&2 fi "$bin" "$@"