configure.ac: Don't try to dump Lisps which we couldn't find.
[runlisp] / runlisp.1.in
... / ...
CommitLineData
1.\" -*-nroff-*-
2.\"
3.\" Manual for `runlisp'
4.\"
5.\" (c) 2020 Mark Wooding
6.\"
7.
8.\"----- Licensing notice ---------------------------------------------------
9.\"
10.\" This file is part of Runlisp, a tool for invoking Common Lisp scripts.
11.\"
12.\" Runlisp is free software: you can redistribute it and/or modify it
13.\" under the terms of the GNU General Public License as published by the
14.\" Free Software Foundation; either version 3 of the License, or (at your
15.\" option) any later version.
16.\"
17.\" Runlisp is distributed in the hope that it will be useful, but WITHOUT
18.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19.\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20.\" for more details.
21.\"
22.\" You should have received a copy of the GNU General Public License
23.\" along with Runlisp. If not, see <https://www.gnu.org/licenses/>.
24.
25.ie t \{\
26. ds o \(bu
27. if \n(.g \{\
28. fam P
29. ev an-1
30. fam P
31. ev
32. \}
33.\}
34.el \{\
35. ds o o
36.\}
37.
38.de hP
39.IP
40\h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c
41..
42.
43.\"--------------------------------------------------------------------------
44.TH runlisp 1 "2 August 2020" "Mark Wooding"
45.SH NAME
46runlisp \- run Common Lisp programs as scripts
47.
48.\"--------------------------------------------------------------------------
49.SH SYNOPSIS
50.
51.B runlisp
52.RI [ options ]
53.RB [ \-\- ]
54.I script
55.RI [ arguments
56\&...]
57.br
58.B runlisp
59.RI [ options ]
60.RB [ \-e
61.IR form ]
62.RB [ \-l
63.IR file ]
64.RB [ \-p
65.IR form ]
66.RB [ \-\- ]
67.RI [ arguments
68\&...]
69.PP
70where
71.I options
72is
73.br
74 \&
75.RB [ \-CDEnqv ]
76.RB [ +DEn ]
77.RB [ \-L
78.IB sys , sys , \fR...]
79.RB [ \-c
80.IR conf ]
81.RB [ \-o
82.RI [ sect \c
83.BR : ] \c
84.IB var = \c
85.IR value ]
86.
87.\"--------------------------------------------------------------------------
88.SH DESCRIPTION
89.
90The
91.B runlisp
92program has two main functions.
93.hP 1.
94It can be used in a script's
95.RB ` #! '
96line to run a Common Lisp script.
97.hP 2.
98It can be used in build scripts
99to invoke a Common Lisp system,
100e.g., to build a standalone program.
101.
102.SS "Options"
103Options are read from the command line, as usual,
104but also (by default) from the script's second line,
105following a
106.RB ` @RUNLISP: '
107marker: see
108.B Operation
109below for the details.
110.
111.PP
112The options accepted are as follows.
113.
114.TP
115.BR "\-h" ", " "\-\-help"
116Write a synopsis of
117.BR query-runlisp-config 's
118command-line syntax
119and a description of the command-line options
120to standard output
121and immediately exit with status 0.
122.
123.TP
124.BR "\-V" ", " "\-\-version"
125Write
126.BR query-runlisp-config 's
127version number
128to standard output
129and immediately exit with status 0.
130.
131.TP
132.BR "\-D" ", " "\-\-vanilla-image"
133Don't check for a custom Lisp image.
134Usually,
135.B runlisp
136tries to start Lisp systems using a custom image,
137so that they'll start more quickly;
138the
139.RB ` \-D '
140option forces the use of the default `vanilla' image
141provided with the system.
142There's not usually any good reason to prefer the vanilla image,
143except for performance comparisons, or debugging
144.B runlisp
145itself.
146Negate with
147.B +D
148or
149.BR \-\-no-vanilla-image .
150.
151.TP
152.BR "\-E" ", " "\-\-command-line-only"
153Don't read embedded options from the
154second line of the
155.I script
156file.
157Negate with
158.B +E
159or
160.BR \-\-no-command-line-only .
161This has no effect in eval mode.
162which is set at compile time.
163.
164.TP
165.BI "\-L" "\fR, " "\-\-accept-lisp=" sys , sys ,\fR...
166Use one of the named Lisp systems.
167Each
168.I sys
169must name a supported Lisp system;
170the names are separated by a comma
171.RB ` , '
172and/or one or more whitespace characters.
173This option may be given more than once:
174the effect is the same as a single option
175listing all of the systems named, in the same order.
176If a system is named more than once,
177a warning is issued (at verbosity level 1 or higher),
178and all but the first occurrence is ignored.
179.
180.TP
181.BI "\-c" "\fR, " "\-\-config-file=" conf
182Read configuration from
183.IR conf .
184If
185.I conf
186is a directory, then all of the files within
187whose names end with
188.RB ` .conf ',
189are loaded, in ascending lexicographical order;
190otherwise,
191.I conf
192is opened as a file.
193All of the files are expected to as described in
194.BR runlisp.conf (5).
195.
196.TP
197.BI "\-e" "\fR, " "\-\-evaluate-expression=" expr
198Evaluate the expression(s)
199.I expr
200and discard the resulting values.
201This option causes
202.B runlisp
203to execute in
204.I eval
205mode.
206.
207.TP
208.BI "\-l" "\fR, " "\-\-load-file=" file
209Read and evaluate forms from the
210.IR file .
211This option causes
212.B runlisp
213to execute in
214.I eval
215mode.
216.
217.TP
218.BR "\-n" ", " "-\-dry-run"
219Don't actually start the Lisp environment.
220This may be helpful for the curious,
221in conjunction with
222.RB ` \-v '
223to increase the verbosity.
224Negate with
225.B +n
226or
227.BR "\-\-no-dry-run" .
228.
229.TP
230.BI "\-p" "\fR, " "\-\-print-expressin=" expr
231Evaluate the expression(s)
232.I expr
233and print the resulting value(s)
234to standard output
235(as if by
236.BR prin1 ).
237If a form produces multiple values,
238they are printed on a single line,
239separated by a single space character;
240if a form produces no values at all,
241then nothing is printed \(en not even a newline character.
242This option causes
243.B runlisp
244to execute in
245.I eval
246mode.
247.
248.TP
249.BR "\-q" ", " "\-\-quiet"
250Don't print warning messages.
251This option may be repeated:
252each use reduces verbosity by one step,
253counteracting one
254.RB ` \-v '
255option.
256The default verbosity level is 1,
257which prints only warning measages.
258.
259.TP
260.BR "\-v" ", " "\-\-verbose"
261Print informational or debugging messages.
262This option may be repeated:
263each use increases verbosity by one step,
264counteracting one
265.RB ` \-q '
266option.
267The default verbosity level is 1,
268which prints only warning measages.
269Higher verbosity levels print informational and debugging messages.
270.
271.PP
272The
273.RB ` \-e ',
274.RB ` \-l ',
275and
276.RB ` \-p '
277options may only be given on the command-line itself,
278not following a
279.RB `@ RUNLISP: '
280marker in a script.
281These options may be given multiple times:
282they will be processed in the order given.
283If any of these options is given, then no
284.I script
285name will be parsed;
286instead, use
287.RB ` \-l '
288to load code from files.
289The
290.IR arguments ,
291ppif any,
292are still made available to the evaluated forms and loaded files.
293.
294.SS "Operation"
295The
296.B runlisp
297program behaves as follows.
298.
299.hP 1.
300The first thing it does is parse its command line.
301Options must precede positional arguments,
302though the boundary may be marked explicitly using
303.RB ` \-\- '
304if desired.
305If the command line contains any of
306.RB ` \-e ',
307.RB ` \-l ',
308or
309.RB ` \-p ',
310then
311.B runlisp
312treats all of its positional arguments as
313.I arguments
314to provide to the given forms and files,
315and runs in
316.I eval
317mode;
318otherwise, the first positional argument becomes the
319.I script
320name, the remaining ones become
321.IR arguments ,
322and
323.B runlisp
324runs in
325.I script
326mode.
327.hP 2.
328In
329.I script
330mode,
331.B runlisp
332reads the second line of the script file,
333and checks to see if it contains the string
334.RB ` @RUNLISP: '.
335If so, then the following text is parsed
336for
337.IR "embedded options" ,
338as follows.
339.RS
340.PP
341The text is split into words
342separated by sequences of whitespace characters.
343Whitespace,
344and other special characters,
345can be included in a word by
346.I quoting
347or
348.IR escaping .
349Text between single quotes
350.BR ' ... '
351is included literally, without any further interpretation;
352text between double quotes
353.BR """" ... """"
354is treated literally,
355except that escaping can still be used
356to escape (e.g.) double quotes and the escape character itself.
357Outside of single quotes, a backslash
358.RB ` \e '
359causes the following character to be included in a word
360regardless of its usual meaning.
361(None of this allows a newline character
362to be included in a word:
363this is simply not possible.)
364A word which is
365.RB ` \-\- '
366before processing quoting and escaping
367marks the end of embedded options.
368As a concession to Emacs users,
369if the sequence
370.RB ` \-*\- '
371appears at the start of a word
372before processing quoting and escaping,
373then everything up to and including the next occurrence of
374.RB ` \-*\- '
375is ignored.
376.PP
377The resulting list of words
378is processed as if it held further command-line options.
379Currently, only
380.RB ` \-D '
381and
382.RB ` \-L '
383options are permitted in embedded option lists:
384.RB ` \-h '
385and
386.RB ` \-v '
387are clearly only useful in interactive use;
388setting
389.RB ` \-q '
390or
391.RB ` \-v '
392would just be annoying;
393setting
394.RB ` \-c '
395or
396.RB ` \-o '
397would override the user's command-line settings;
398it's clearly too late to set
399.RB ` \-E ';
400and
401.B runlisp
402is now committed to
403.I script
404mode, so it's too late for
405.RB ` \-e ',
406.RB ` \-l ',
407and
408.RB ` \-p '
409too.
410.PP
411(This feature allows scripts to provide options even if they use
412.BR env (1)
413to find
414.B runlisp
415on the
416.BR PATH ,
417or to provide more than one option,
418since many operating systems pass the text following
419the interpreter name on a
420.RB ` #! '
421line as a single argument, without further splitting it at spaces.)
422.RE
423.
424.hP 3.
425If no
426.RB ` \-c '
427options were given,
428then the default configuration files are read:
429the system configuration from
430.B @etcdir@/runlisp.conf
431and
432.BR @etcdir@/runlisp.d/*.conf ,
433and the user configuration from
434.B ~/.runlisp.conf
435and/or
436.BR ~/.config/runlisp.conf :
437see
438.RB runlisp.conf (5)
439for the details.
440.
441.hP 4.
442The list of
443.I "acceptable Lisp implementations"
444is determined.
445If any
446.RB ` \-L '
447options have been found,
448then the list of acceptable implementations
449consists of all of the implementations mentioned in
450.RB ` -L '
451options
452in any of the places
453.B runlisp
454looked for options,
455in the order of their first occurrence.
456(If an implementation is named more than once,
457then
458.B runlisp
459prints a warning to stderr
460and ignores all but the first occurrence.)
461If no
462.RB ` \-L '
463option is given, then
464.B runlisp
465uses a default list,
466which consists of all of the Lisp implementations
467defined in its configuration,
468in the order in which they were defined.
469.
470.hP 5.
471The list of
472.I "preferred Lisp implementations"
473is determined.
474If the environment variable
475.B RUNLISP_PREFER
476is set,
477then its value should be a list of names of Lisp implementations
478separated by a comma and/or one or more whitespace characters.
479Otherwise, if there is a setting for the variable
480.B prefer
481in the
482.B @CONFIG
483configuration section,
484then its (expanded) value should be a list of Lisp implementations,
485in the same way.
486Otherwise, the list of preferred implementations is empty.
487.
488.hP 6.
489If
490.B runlisp
491is running in
492.I eval
493mode, then a new command line is built,
494which invokes an internal script,
495instructing it to evaluate and print the requested expressions,
496and load the requested files.
497.
498.hP 7.
499Acceptable Lisp implementations are tried in turn.
500First, the preferred implementations
501which are also listed as acceptable implementations
502are tried, in the order in which they appear
503in the preferred implementations list;
504then, the remaining acceptable implementations are tried
505in the order in which they appear
506in the acceptable implementations list.
507.RS
508.PP
509A Lisp implementation is defined by a configuration section
510which defines a variable
511.BR run-script .
512The name of the configuration section
513is the name of the Lisp implementation,
514as used in the acceptable and preferred lists described above.
515.hP (a)
516The variable
517.B image-file
518is looked up in the configuration section.
519If a value is found, then
520.B runlisp
521looks up and expands
522.BR image-path ,
523and checks to see if a file exists with the resulting name.
524If so, it sets the variable
525.B @image
526to
527.B t
528in the configuration section.
529.hP (b)
530The variable
531.B run-script
532is expanded and word-split.
533The
534.I script
535(an internal script, in
536.I eval
537mode)
538and
539.IR argument s
540are appended, and
541the entire list is passed to the
542.BR execvp (3)
543function.
544If that succeeds, the Lisp implementation runs;
545if it fails with
546.B ENOENT
547then other Lisp systems are tried;
548if it fails with some other error, then
549.B runlisp
550reports an error message to stderr
551and exits unsuccessfully
552(with code 127).
553If the
554.RB ` \-n '
555option was given, then
556.B runlisp
557just simulates the behaviour of
558.BR execvp (3),
559printing messages to stderr
560if the verbosity level is sufficiently high,
561and exits.
562.
563.SS "Script environment"
564Many Lisp implementations don't provide a satisfactory environment
565for scripts to run in.
566The actual task of invoking a Lisp implementation
567is left to configuration,
568but the basic configuration supplied with
569.B runlisp
570ensures the following facts about their environment.
571.hP \*o
572The keyword
573.B :runlisp-script
574is added to the
575.B *features*
576list if
577.B runlisp
578is running in
579.I script
580mode.
581.hP \*o
582Most Lisp systems support a user initialization file
583which they load before entering the REPL;
584some also have a system initialization file.
585The
586.B runlisp
587program arranges
588.I not
589to read these files,
590so that the Lisp environment is reasonably predictable,
591and to avoid slowing down script startup
592with things which are convenient for use in an interactive session,
593but can't be relied upon by a script anyway.
594.hP \*o
595The Unix standard input, standard output, and standard error files
596are available through the Lisp
597.BR *standard-input* ,
598.BR *standard-output* ,
599and
600.BR *error-output*
601streams, respectively.
602.hP \*o
603Both
604.B *compile-verbose*
605and
606.B *load-verbose*
607are set to nil.
608On CMU\ CL,
609.B ext:*require-verbose*
610is also nil.
611Alas, this is insufficient to muffle noise while loading add-on systems
612on some implementations.
613.hP \*o
614If an error is signalled, and not caught by user code,
615then the process will print a message to stderr
616and exit with a nonzero status.
617The reported message may be a long, ugly backtrace,
618or a terse error report.
619If no error is signalled but not caught,
620then the process will exit with status 0.
621.hP \*o
622The initial package is
623.BR COMMON-LISP-USER ,
624which has no symbols `present' (i.e., imported or interned).
625.hP \*o
626The
627.B asdf
628and
629.B uiop
630systems are already loaded.
631Further systems can be loaded using
632.B asdf:load-system
633as usual.
634The script name
635(which is only meaningful if
636.B runlisp
637is in
638.I script
639mode, obviously)
640and arguments are available through the
641.B uiop:argv0
642function and
643.B uiop:*command-line-arguments*
644variable, respectively.
645.
646.\"--------------------------------------------------------------------------
647.
648.SH BUGS
649.hP \*o
650Loading ASDF systems is irritatingly noisy
651with some Lisp implementations.
652Suggestions for how to improve this are welcome.
653.hP \*o
654More Lisp implementations should be supported.
655I've supported the ones I have installed.
656I'm not willing to put a great deal of effort into supporting
657non-free Lisp implementations;
658but help supporting free Lisps is much appreciated.
659.hP \*o
660The protocol for passing the script name through to
661.B uiop
662(specifically, through the
663.B __CL_ARGV0
664environment variable)
665is terribly fragile,
666but supporting
667.B uiop
668is obviously a better approach than introducing a
669.BR runlisp -specific
670interface to the same information.
671I don't know how to fix this:
672suggestions are welcome.
673.
674.SH SEE ALSO
675.BR dump-runlisp-image (1),
676.BR query-runlisp-config (1),
677.BR runlisp.conf (5).
678.
679.SH AUTHOR
680Mark Wooding, <mdw@distorted.org.uk>
681.
682.\"----- That's all, folks --------------------------------------------------