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