-
Notifications
You must be signed in to change notification settings - Fork 3
/
smlrepl
executable file
·58 lines (45 loc) · 1.09 KB
/
smlrepl
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
50
51
52
53
54
55
56
57
#!/bin/bash
#
# smlrepl - load a SML program defined in a MLB file into the SML/NJ
# interactive environment
#
# Chris Cannam, 2015-2022. MIT licence
set -e
usage() {
me=$(basename "$0")
echo 1>&2
echo "$me: Load a SML program defined in a MLB file into the SML/NJ repl" 1>&2
echo 1>&2
echo "Usage: $me file.sml" 1>&2
echo " $me [-u] file.mlb" 1>&2
echo "where" 1>&2
echo " -u: Unique: \"use\" each file only once, regardless of how many times it" 1>&2
echo " appears in the MLB file. See \"polybuild\" for discussion." 1>&2
echo 1>&2
exit 2
}
if echo | sml | grep -q Jersey ; then :
else
echo "*** Error: SML/NJ binary 'sml' not in path" 1>&2
exit 1
fi
unique_arg=""
if [ "$1" = "-u" ]; then
unique_arg="-u"
shift
fi
arg="$1"
if [ -z "$arg" ]; then
usage
fi
shift
set -u
mydir=$(dirname "$0")
. "$mydir/smlbuild-include.sh"
out=$(get_outfile "$arg")
tmpout=$(get_tmpsmlfile "$arg")
trap "rm -f ${tmpout}" 0
expand_arg $unique_arg "$arg" | \
sed 's/^\(.*\)$/use "\1";/' > \
"$tmpout"
rlwrap sml "$tmpout" "$@"