-
Notifications
You must be signed in to change notification settings - Fork 0
/
with_lisp_implementation
executable file
·101 lines (88 loc) · 1.9 KB
/
with_lisp_implementation
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
# with_lisp_implementation — Load Lisp Scripts with the given implementation
# Melusina Actions (https://github.com/melusina-org/make-common-lisp-program)
# This file is part of Melusina Actions.
#
# Copyright © 2023 Michaël Le Barbier
# All rights reserved.
# This file must be used under the terms of the MIT License.
# This source file is licensed as described in the file LICENSE, which
# you should have received as part of this distribution. The terms
# are also available at https://opensource.org/licenses/MIT
: ${lisp_implementation:='sbcl'}
lisp_load_file()
(
local argv script
renaissance_lisp()
{
set -- "$@" --break
while true; do
case "$1" in
*.lisp)
set -- "$@" --load "$1"
shift
;;
'('*')')
set -- "$@" --eval "$1"
shift
;;
--break)
set -- "$@" --eval '(quit)'
shift
break
;;
*)
1>&2 printf 'Failure: %s: Cannot process argument.\n' "$1"
exit 64
;;
esac
done
case "${lisp_implementation}" in
sbcl)
set -- --disable-debugger "$@"
;;
ecl)
set -- --nodebug "$@"
;;
esac
exec "${lisp_implementation}" "$@"
}
if [ $# -eq 0 ]; then
script="$(mktemp).lisp"
trap "rm -f ${script}" EXIT TERM INT
cat > "${script}"
set -- "${script}"
fi
case "${lisp_implementation}" in
abcl|ecl|sbcl)
renaissance_lisp "$@"
;;
clisp)
ubuntu_asdf="/usr/share/common-lisp/source/cl-asdf/asdf.lisp"
if [ -f "${ubuntu_asdf}" ]; then
set -- "${ubuntu_asdf}" "$@"
fi
exec clisp "$@"
;;
*)
set -x
"${lisp_implementation}" -h
"${lisp_implementation}" --help
exit 1
;;
esac
)
lisp_main()
{
case "$1" in
abcl|clasp|clisp|ecl|gcl|sbcl)
lisp_implementation="$1"
shift
;;
*)
exit 70
esac
lisp_load_file "$@"
}
lisp_main "$@"
# End of file `with_lisp_implementation'