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