-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsecdscheme
executable file
·51 lines (41 loc) · 931 Bytes
/
secdscheme
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
#!/bin/bash
DIR=`dirname $0`
SECDVM=$DIR/secd
COMPILER=$DIR/scm2secd.secd
REPLSRC=$DIR/repl.scm
REPL=$DIR/repl.secd
die () {
echo $@ >&2
exit 1
}
interp () {
RLWRAP="`which rlwrap`"
[ "$RLWRAP" ] && RLWRAP="$RLWRAP -r -q \"\\\"\" "
exec $RLWRAP $SECDVM $REPL
}
compile () {
case "$1" in
*.scm) ;;
*) die "Error: file $1 must have .scm extension" ;;
esac
SRC="$1"
DST="${1/scm/secd}"
# backup destination if needed
[ -e "$DST" ] && mv "$DST" "$DST~"
$SECDVM $COMPILER <$SRC >"${DST}.1" || die "Error: compilation failed"
mv "${DST}.1" $DST
exit 0
}
test -f "$REPL" || {
export REPL="$DIR/../share/secdscheme/secd/repl.secd"
test -f "$REPL" || die "repl.secd not found"
}
# is there the secd interpreter?
[ -x $SECDVM ] || die "$SECDVM not found"
if [ "$1" = '-c' ] ; then
shift
echo ";; compiling $@..." >&2
compile "$@"
else
interp
fi