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