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