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