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
44 .\"--------------------------------------------------------------------------
45 .TH runlisp 1 "2 August 2020" "Mark Wooding"
47 runlisp \- run Common Lisp programs as scripts
49 .\"--------------------------------------------------------------------------
85 .IB sys , sys , \fR\*(..]
98 .\"--------------------------------------------------------------------------
103 program has two main functions.
105 It can be used in a script's
107 line to run a Common Lisp script.
109 It can be used in build scripts
110 to invoke a Common Lisp system,
111 e.g., to build a standalone program.
114 Options are read from the command line, as usual,
115 but also (by default) from the script's second line,
120 below for the details.
123 The options accepted are as follows.
126 .BR "\-h" ", " "\-\-help"
128 .BR query-runlisp-config 's
130 and a description of the command-line options
132 and immediately exit with status 0.
135 .BR "\-V" ", " "\-\-version"
137 .BR query-runlisp-config 's
140 and immediately exit with status 0.
143 .BR "\-D" ", " "\-\-vanilla-image"
144 Don't check for a custom Lisp image.
147 tries to start Lisp systems using a custom image,
148 so that they'll start more quickly;
151 option forces the use of the default `vanilla' image
152 provided with the system.
153 There's not usually any good reason to prefer the vanilla image,
154 except for performance comparisons, or debugging
160 .BR \-\-no-vanilla-image .
163 .BR "\-E" ", " "\-\-command-line-only"
164 Don't read embedded options from the
171 .BR \-\-no-command-line-only .
172 This has no effect in eval mode.
173 which is set at compile time.
176 .BI "\-L" "\fR, " "\-\-accept-lisp=" sys , sys ,\fR\*(..
177 Use one of the named Lisp systems.
180 must name a supported Lisp system;
181 the names are separated by a comma
183 and/or one or more whitespace characters.
184 This option may be given more than once:
185 the effect is the same as a single option
186 listing all of the systems named, in the same order.
187 If a system is named more than once,
188 a warning is issued (at verbosity level 1 or higher),
189 and all but the first occurrence is ignored.
192 .BI "\-c" "\fR, " "\-\-config-file=" conf
193 Read configuration from
197 is a directory, then all of the files within
200 are loaded, in ascending lexicographical order;
204 All of the files are expected to be as described in
205 .BR runlisp.conf (5).
208 .BI "\-d" "\fR, " "\-\-dump-expression=" expr
209 Evaluate the expression(s)
211 and print the resulting value(s)
217 If a form produces multiple values,
218 they are printed on a single line,
219 separated by a single space character;
220 if a form produces no values at all,
221 then nothing is printed \(en not even a newline character.
234 .BI "\-e" "\fR, " "\-\-evaluate-expression=" expr
235 Evaluate the expression(s)
237 and discard the resulting values.
245 .BI "\-l" "\fR, " "\-\-load-file=" file
246 Read and evaluate forms from the
255 .BR "\-n" ", " "\-\-dry-run"
256 Don't actually start the Lisp environment.
257 This may be helpful for the curious,
260 to increase the verbosity.
264 .BR "\-\-no-dry-run" .
267 .BI "\-o" "\fR, " "\-\-set-option=\fR[" sect :\fR] var = value
272 in configuration section
276 if no section is specified.
277 The value is unexpandable,
278 and overrides any similarly named setting
279 from the configuration file(s).
282 .BI "\-p" "\fR, " "\-\-print-expression=" expr
283 Evaluate the expression(s)
285 and print the resulting value(s)
291 If a form produces multiple values,
292 they are printed on a single line,
293 separated by a single space character;
294 if a form produces no values at all,
295 then nothing is printed \(en not even a newline character.
308 .BR "\-q" ", " "\-\-quiet"
309 Don't print warning messages.
310 This option may be repeated:
311 each use reduces verbosity by one step,
315 The default verbosity level is 1,
316 which prints only warning measages.
319 .BR "\-v" ", " "\-\-verbose"
320 Print informational or debugging messages.
321 This option may be repeated:
322 each use increases verbosity by one step,
326 The default verbosity level is 1,
327 which prints only warning measages.
328 Higher verbosity levels print informational and debugging messages.
337 options may only be given on the command-line itself,
341 These options may be given multiple times:
342 they will be processed in the order given.
343 If any of these options is given, then no
348 to load code from files.
352 are still made available to the evaluated forms and loaded files.
357 program behaves as follows.
360 The first thing it does is parse its command line.
361 Options must precede positional arguments,
362 though the boundary may be marked explicitly using
365 If the command line contains any of
373 treats all of its positional arguments as
375 to provide to the given forms and files,
379 otherwise, the first positional argument becomes the
381 name, the remaining ones become
393 reads the second line of the script file,
394 and checks to see if it contains the string
396 If so, then the following text is parsed
398 .IR "embedded options" ,
402 The text is split into words
403 separated by sequences of whitespace characters.
405 and other special characters,
406 can be included in a word by
410 Text between single quotes
412 is included literally, without any further interpretation;
413 text between double quotes
415 is treated literally,
416 except that escaping can still be used
417 to escape (e.g.) double quotes and the escape character itself.
418 Outside of single quotes, a backslash
420 causes the following character to be included in a word
421 regardless of its usual meaning.
422 (None of this allows a newline character
423 to be included in a word:
424 this is simply not possible.)
427 before processing quoting and escaping
428 marks the end of embedded options.
429 As a concession to Emacs users,
432 appears at the start of a word
433 before processing quoting and escaping,
434 then everything up to and including the next occurrence of
438 The resulting list of words
439 is processed as if it held further command-line options.
444 options are permitted in embedded option lists:
448 are clearly only useful in interactive use;
453 would just be annoying;
458 would override the user's command-line settings;
459 it's clearly too late to set
465 mode, so it's too late for
473 (This feature allows scripts to provide options even if they use
479 or to provide more than one option,
480 since many operating systems pass the text following
481 the interpreter name on a
483 line as a single argument, without further splitting it at spaces.)
490 then the default configuration files are read:
491 the system configuration from
492 .B @etcdir@/runlisp.conf
494 .BR @etcdir@/runlisp.d/*.conf ,
495 and the user configuration from
498 .BR ~/.config/runlisp.conf :
505 .I "acceptable Lisp implementations"
509 options have been found,
510 then the list of acceptable implementations
511 consists of all of the implementations mentioned in
517 in the order of their first occurrence.
518 (If an implementation is named more than once,
521 prints a warning to stderr
522 and ignores all but the first occurrence.)
525 option is given, then
528 which consists of all of the Lisp implementations
529 defined in its configuration,
530 in the order in which they were defined.
534 .I "preferred Lisp implementations"
536 If the environment variable
539 then its value should be a list of names of Lisp implementations
540 separated by a comma and/or one or more whitespace characters.
541 Otherwise, if there is a setting for the variable
545 configuration section,
546 then its (expanded) value should be a list of Lisp implementations,
548 Otherwise, the list of preferred implementations is empty.
555 mode, then a new command line is built,
556 which invokes an internal script,
557 instructing it to evaluate and print the requested expressions,
558 and load the requested files.
561 Acceptable Lisp implementations are tried in turn.
562 First, the preferred implementations
563 which are also listed as acceptable implementations
564 are tried, in the order in which they appear
565 in the preferred implementations list;
566 then, the remaining acceptable implementations are tried
567 in the order in which they appear
568 in the acceptable implementations list.
571 A Lisp implementation is defined by a configuration section
572 which defines a variable
574 The name of the configuration section
575 is the name of the Lisp implementation,
576 as used in the acceptable and preferred lists described above.
580 is looked up in the configuration section.
581 If a value is found, then
585 and checks to see if a file exists with the resulting name.
586 If so, it sets the variable
590 in the configuration section.
594 is expanded and word-split.
597 (an internal script, in
603 the entire list is passed to the
606 If that succeeds, the Lisp implementation runs;
609 then other Lisp systems are tried;
610 if it fails with some other error, then
612 reports an error message to stderr
613 and exits unsuccessfully
617 option was given, then
619 just simulates the behaviour of
621 printing messages to stderr
622 if the verbosity level is sufficiently high,
625 .SS "Script environment"
626 Many Lisp implementations don't provide a satisfactory environment
627 for scripts to run in.
628 The actual task of invoking a Lisp implementation
629 is left to configuration,
630 but the basic configuration supplied with
632 ensures the following facts about their environment.
644 Most Lisp systems support a user initialization file
645 which they load before entering the REPL;
646 some also have a system initialization file.
652 so that the Lisp environment is reasonably predictable,
653 and to avoid slowing down script startup
654 with things which are convenient for use in an interactive session,
655 but can't be relied upon by a script anyway.
657 The Unix standard input, standard output, and standard error files
658 are available through the Lisp
659 .BR *standard-input* ,
660 .BR *standard-output* ,
663 streams, respectively.
671 .B ext:*require-verbose*
673 Alas, this is insufficient to muffle noise while loading add-on systems
674 on some implementations.
676 If an error is signalled, and not caught by user code,
677 then the process will print a message to stderr
678 and exit with a nonzero status.
679 The reported message may be a long, ugly backtrace,
680 or a terse error report.
681 If no error is signalled but not caught,
682 then the process will exit with status 0.
684 The initial package is
685 .BR COMMON-LISP-USER ,
686 which has no symbols `present' (i.e., imported or interned).
692 systems are already loaded.
693 Further systems can be loaded using
697 (which is only meaningful if
702 and arguments are available through the
705 .B uiop:*command-line-arguments*
706 variable, respectively.
708 .\"--------------------------------------------------------------------------
712 Loading ASDF systems is irritatingly noisy
713 with some Lisp implementations.
714 Suggestions for how to improve this are welcome.
716 More Lisp implementations should be supported.
717 I've supported the ones I have installed.
718 I'm not willing to put a great deal of effort into supporting
719 non-free Lisp implementations;
720 but help supporting free Lisps is much appreciated.
722 The protocol for passing the script name through to
724 (specifically, through the
726 environment variable)
730 is obviously a better approach than introducing a
731 .BR runlisp -specific
732 interface to the same information.
733 I don't know how to fix this:
734 suggestions are welcome.
737 .BR dump-runlisp-image (1),
738 .BR query-runlisp-config (1),
739 .BR runlisp.conf (5).
742 Mark Wooding, <mdw@distorted.org.uk>
744 .\"----- That's all, folks --------------------------------------------------