3 .\" Manual for `runlisp'
5 .\" (c) 2020 Mark Wooding
8 .\"----- Licensing notice ---------------------------------------------------
10 .\" This file is part of Runlisp, a tool for invoking Common Lisp scripts.
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.
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
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/>.
40 \h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c
43 .\"--------------------------------------------------------------------------
44 .TH runlisp 1 "2 August 2020" "Mark Wooding"
46 runlisp \- run Common Lisp programs as scripts
48 .\"--------------------------------------------------------------------------
78 .IB sys , sys , \fR...]
91 .\"--------------------------------------------------------------------------
96 program has two main functions.
98 It can be used in a script's
100 line to run a Common Lisp script.
102 It can be used in build scripts
103 to invoke a Common Lisp system,
104 e.g., to build a standalone program.
107 Options are read from the command line, as usual,
108 but also (by default) from the script's second line,
113 below for the details.
116 The options accepted are as follows.
119 .BR "\-h" ", " "\-\-help"
121 .BR query-runlisp-config 's
123 and a description of the command-line options
125 and immediately exit with status 0.
128 .BR "\-V" ", " "\-\-version"
130 .BR query-runlisp-config 's
133 and immediately exit with status 0.
136 .BR "\-D" ", " "\-\-vanilla-image"
137 Don't check for a custom Lisp image.
140 tries to start Lisp systems using a custom image,
141 so that they'll start more quickly;
144 option forces the use of the default `vanilla' image
145 provided with the system.
146 There's not usually any good reason to prefer the vanilla image,
147 except for performance comparisons, or debugging
153 .BR \-\-no-vanilla-image .
156 .BR "\-E" ", " "\-\-command-line-only"
157 Don't read embedded options from the
164 .BR \-\-no-command-line-only .
165 This has no effect in eval mode.
166 which is set at compile time.
169 .BI "\-L" "\fR, " "\-\-accept-lisp=" sys , sys ,\fR...
170 Use one of the named Lisp systems.
173 must name a supported Lisp system;
174 the names are separated by a comma
176 and/or one or more whitespace characters.
177 This option may be given more than once:
178 the effect is the same as a single option
179 listing all of the systems named, in the same order.
180 If a system is named more than once,
181 a warning is issued (at verbosity level 1 or higher),
182 and all but the first occurrence is ignored.
185 .BI "\-c" "\fR, " "\-\-config-file=" conf
186 Read configuration from
190 is a directory, then all of the files within
193 are loaded, in ascending lexicographical order;
197 All of the files are expected to be as described in
198 .BR runlisp.conf (5).
201 .BI "\-e" "\fR, " "\-\-evaluate-expression=" expr
202 Evaluate the expression(s)
204 and discard the resulting values.
212 .BI "\-l" "\fR, " "\-\-load-file=" file
213 Read and evaluate forms from the
222 .BR "\-n" ", " "\-\-dry-run"
223 Don't actually start the Lisp environment.
224 This may be helpful for the curious,
227 to increase the verbosity.
231 .BR "\-\-no-dry-run" .
234 .BI "\-p" "\fR, " "\-\-print-expressin=" expr
235 Evaluate the expression(s)
237 and print the resulting value(s)
241 If a form produces multiple values,
242 they are printed on a single line,
243 separated by a single space character;
244 if a form produces no values at all,
245 then nothing is printed \(en not even a newline character.
253 .BR "\-q" ", " "\-\-quiet"
254 Don't print warning messages.
255 This option may be repeated:
256 each use reduces verbosity by one step,
260 The default verbosity level is 1,
261 which prints only warning measages.
264 .BR "\-v" ", " "\-\-verbose"
265 Print informational or debugging messages.
266 This option may be repeated:
267 each use increases verbosity by one step,
271 The default verbosity level is 1,
272 which prints only warning measages.
273 Higher verbosity levels print informational and debugging messages.
281 options may only be given on the command-line itself,
285 These options may be given multiple times:
286 they will be processed in the order given.
287 If any of these options is given, then no
292 to load code from files.
296 are still made available to the evaluated forms and loaded files.
301 program behaves as follows.
304 The first thing it does is parse its command line.
305 Options must precede positional arguments,
306 though the boundary may be marked explicitly using
309 If the command line contains any of
316 treats all of its positional arguments as
318 to provide to the given forms and files,
322 otherwise, the first positional argument becomes the
324 name, the remaining ones become
336 reads the second line of the script file,
337 and checks to see if it contains the string
339 If so, then the following text is parsed
341 .IR "embedded options" ,
345 The text is split into words
346 separated by sequences of whitespace characters.
348 and other special characters,
349 can be included in a word by
353 Text between single quotes
355 is included literally, without any further interpretation;
356 text between double quotes
358 is treated literally,
359 except that escaping can still be used
360 to escape (e.g.) double quotes and the escape character itself.
361 Outside of single quotes, a backslash
363 causes the following character to be included in a word
364 regardless of its usual meaning.
365 (None of this allows a newline character
366 to be included in a word:
367 this is simply not possible.)
370 before processing quoting and escaping
371 marks the end of embedded options.
372 As a concession to Emacs users,
375 appears at the start of a word
376 before processing quoting and escaping,
377 then everything up to and including the next occurrence of
381 The resulting list of words
382 is processed as if it held further command-line options.
387 options are permitted in embedded option lists:
391 are clearly only useful in interactive use;
396 would just be annoying;
401 would override the user's command-line settings;
402 it's clearly too late to set
408 mode, so it's too late for
415 (This feature allows scripts to provide options even if they use
421 or to provide more than one option,
422 since many operating systems pass the text following
423 the interpreter name on a
425 line as a single argument, without further splitting it at spaces.)
432 then the default configuration files are read:
433 the system configuration from
434 .B @etcdir@/runlisp.conf
436 .BR @etcdir@/runlisp.d/*.conf ,
437 and the user configuration from
440 .BR ~/.config/runlisp.conf :
447 .I "acceptable Lisp implementations"
451 options have been found,
452 then the list of acceptable implementations
453 consists of all of the implementations mentioned in
459 in the order of their first occurrence.
460 (If an implementation is named more than once,
463 prints a warning to stderr
464 and ignores all but the first occurrence.)
467 option is given, then
470 which consists of all of the Lisp implementations
471 defined in its configuration,
472 in the order in which they were defined.
476 .I "preferred Lisp implementations"
478 If the environment variable
481 then its value should be a list of names of Lisp implementations
482 separated by a comma and/or one or more whitespace characters.
483 Otherwise, if there is a setting for the variable
487 configuration section,
488 then its (expanded) value should be a list of Lisp implementations,
490 Otherwise, the list of preferred implementations is empty.
497 mode, then a new command line is built,
498 which invokes an internal script,
499 instructing it to evaluate and print the requested expressions,
500 and load the requested files.
503 Acceptable Lisp implementations are tried in turn.
504 First, the preferred implementations
505 which are also listed as acceptable implementations
506 are tried, in the order in which they appear
507 in the preferred implementations list;
508 then, the remaining acceptable implementations are tried
509 in the order in which they appear
510 in the acceptable implementations list.
513 A Lisp implementation is defined by a configuration section
514 which defines a variable
516 The name of the configuration section
517 is the name of the Lisp implementation,
518 as used in the acceptable and preferred lists described above.
522 is looked up in the configuration section.
523 If a value is found, then
527 and checks to see if a file exists with the resulting name.
528 If so, it sets the variable
532 in the configuration section.
536 is expanded and word-split.
539 (an internal script, in
545 the entire list is passed to the
548 If that succeeds, the Lisp implementation runs;
551 then other Lisp systems are tried;
552 if it fails with some other error, then
554 reports an error message to stderr
555 and exits unsuccessfully
559 option was given, then
561 just simulates the behaviour of
563 printing messages to stderr
564 if the verbosity level is sufficiently high,
567 .SS "Script environment"
568 Many Lisp implementations don't provide a satisfactory environment
569 for scripts to run in.
570 The actual task of invoking a Lisp implementation
571 is left to configuration,
572 but the basic configuration supplied with
574 ensures the following facts about their environment.
586 Most Lisp systems support a user initialization file
587 which they load before entering the REPL;
588 some also have a system initialization file.
594 so that the Lisp environment is reasonably predictable,
595 and to avoid slowing down script startup
596 with things which are convenient for use in an interactive session,
597 but can't be relied upon by a script anyway.
599 The Unix standard input, standard output, and standard error files
600 are available through the Lisp
601 .BR *standard-input* ,
602 .BR *standard-output* ,
605 streams, respectively.
613 .B ext:*require-verbose*
615 Alas, this is insufficient to muffle noise while loading add-on systems
616 on some implementations.
618 If an error is signalled, and not caught by user code,
619 then the process will print a message to stderr
620 and exit with a nonzero status.
621 The reported message may be a long, ugly backtrace,
622 or a terse error report.
623 If no error is signalled but not caught,
624 then the process will exit with status 0.
626 The initial package is
627 .BR COMMON-LISP-USER ,
628 which has no symbols `present' (i.e., imported or interned).
634 systems are already loaded.
635 Further systems can be loaded using
639 (which is only meaningful if
644 and arguments are available through the
647 .B uiop:*command-line-arguments*
648 variable, respectively.
650 .\"--------------------------------------------------------------------------
654 Loading ASDF systems is irritatingly noisy
655 with some Lisp implementations.
656 Suggestions for how to improve this are welcome.
658 More Lisp implementations should be supported.
659 I've supported the ones I have installed.
660 I'm not willing to put a great deal of effort into supporting
661 non-free Lisp implementations;
662 but help supporting free Lisps is much appreciated.
664 The protocol for passing the script name through to
666 (specifically, through the
668 environment variable)
672 is obviously a better approach than introducing a
673 .BR runlisp -specific
674 interface to the same information.
675 I don't know how to fix this:
676 suggestions are welcome.
679 .BR dump-runlisp-image (1),
680 .BR query-runlisp-config (1),
681 .BR runlisp.conf (5).
684 Mark Wooding, <mdw@distorted.org.uk>
686 .\"----- That's all, folks --------------------------------------------------