-
Notifications
You must be signed in to change notification settings - Fork 1
/
args
executable file
·129 lines (114 loc) · 2.39 KB
/
args
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/sh
usage () {
local stream=$1;
if [ -z "$stream" ];
then
stream="1";
fi
echo "Usage: $0 [lisp] [param] ..." >&"$stream";
echo "" >&"$stream";
echo "Valid Common Lisp implementation:" >&"$stream";
echo " sbcl" >&"$stream";
echo " ccl" >&"$stream";
echo " clisp" >&"$stream";
echo " ecl" >&"$stream";
echo " abcl" >&"$stream";
}
# Constants
SBCL="sbcl"
CCL="ccl"
CLISP="clisp"
ECL="ecl"
ABCL="abcl"
lisp=$1;
if [ "-h" = "$lisp" ] || [ "--help" = "$lisp" ];
then
echo "Use \`$0 usage\` or \`$0 help\` to show help info";
exit;
fi
if [ "usage" = "$lisp" ] || [ "help" = "$lisp" ];
then
usage;
exit;
fi
case $lisp in
"$SBCL")
shift;
;;
"$CCL")
shift;
;;
"$CLISP")
shift;
;;
"$ECL")
shift;
;;
"$ABCL")
shift;
;;
*)
echo "Unsupported Common Lisp implementation" >&2;
usage 2;
exit 1;
esac
# Locate the path of the script itself.
root=$(dirname "$0");
if [ "$SBCL" = "$lisp" ];
then
# Check whether SBCL and its wrapper exist.
if ! command -v sbclrun 2>/dev/null 1>&2;
then
echo "No SBCL or its wrapper on the system" >&2;
exit 1;
fi
# Invoke SBCL wrapper.
sbclrun "$root/args.lisp" "$@";
elif [ "$CCL" = "$lisp" ];
then
# Check whether Clozure CL and its wrapper exist.
if ! command -v ccl 2>/dev/null 1>&2;
then
echo "No Clozure CL or its wrapper on the system" >&2;
exit 1;
fi
# `ccl` is a Clozure CL wrapper.
# Hence, there is no need to add `--` here.
ccl "$root/args.lisp" "$@";
elif [ "$CLISP" = "$lisp" ];
then
# Check whether CLISP exists.
if ! command -v clisprun --version 2>/dev/null 1>&2;
then
echo "No CLISP or its wrapper on the system" >&2;
exit 1;
fi
# Invoke CLISP directly.
clisprun "$root/args.lisp" "$@";
elif [ "$ECL" = "$lisp" ];
then
# Check whether ECL exists.
if ! command -v ecl --help 2>/dev/null 1>&2;
then
echo "No ECL on the system" >&2;
exit 1;
fi
# Invoke ECL directly.
if [ "Darwin" = $(uname) ];
then
ecl --shell "$root/args.lisp" "$@";
else
ecl -shell "$root/args.lisp" "$@";
fi
elif [ "$ABCL" = "$lisp" ];
then
# Check whether ABCL and its wrapper exist.
if ! command -v abcl 2>/dev/null 1>&2;
then
echo "No ABCL or its wrapper on the system" >&2;
exit 1;
fi
# `abcl` is an Armed Bear CL wrapper.
# Hence, there is no need to add `--` here.
abcl "$root/args.lisp" "$@";
fi