-
Notifications
You must be signed in to change notification settings - Fork 77
/
run.sh
executable file
·49 lines (39 loc) · 1.27 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
# Run the most recently-modified matterhorn binary in the matterhorn
# working tree.
#
# Portability: Linux, OS X
set -e
HERE=$(cd `dirname $0`; pwd)
# An array of the build directories we'll look for.
TRY_DIRS=("$HERE/dist-newstyle" "$HERE/dist")
function none_found {
echo "No matterhorn build directories found. Looked for:"
for d in ${TRY_DIRS[@]}
do
echo " $d"
done
echo "Try:"
echo " $ cd ${HERE}"
echo " $ ./build.sh"
exit 2
}
# Portability note: -executable is only compatible with GNU find but
# this invocation should be more portable. Also be flexible about old
# and new cabal output locations, preferring new, but avoiding
# slurping up the entire current directory.
FOUND_DIRS=$(for D in ${TRY_DIRS[@]}; do ([ -d "$D" ] && echo $D) || :; done)
if [ -z "${FOUND_DIRS}" ] ; then
none_found
fi
BINARIES=$(find $FOUND_DIRS -name matterhorn -type f \( -perm -u=x -o -perm -g=x -o -perm -o=x \) )
if [ -z "${BINARIES}" ] ; then
none_found
fi
SORTED_BINARIES=$(ls -t ${BINARIES})
# Run the most recently-modified binary that we found. Note that since
# we use exec, this loop never makes it past one iteration.
for BINARY in ${SORTED_BINARIES}; do
exec "${BINARY}" ${1+$@}
done
echo "No executables found."