HTF-0.13.2.4: scripts/local-htfpp
#!/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()
{
bin=$($find "$TOP/$dist" -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, trying to build it" >&2
stack $HTF_TRAVIS_STACK_ARGS build 2> /dev/null > /dev/null
find_bin
if [ -z "$bin" ]; then
echo "Still no executable named htfpp found in $TOP/$dist (even after trying to build it)" >&2
echo "TOP=$TOP" >&2
echo "dist=$dist" >&2
find "$TOP/$dist" -type f >&2
exit 1
fi
fi
"$bin" "$@"