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.
175 .BI "\-L" "\fR, " "\-\-accept-lisp=" sys , sys ,\fR\*(..
176 Use one of the named Lisp systems.
179 names are separated by a comma
181 and/or one or more whitespace characters.
182 This option may be given more than once:
183 the effect is the same as a single option
184 listing all of the systems named, in the same order.
185 If a system is named more than once,
186 a warning is issued (at verbosity level 1 or higher),
187 and all but the first occurrence is ignored.
188 System names which do not refer to known Lisp systems
189 are silently ignored:
190 otherwise, a script which supports an unusual Lisp system
191 could never run at a site which doesn't have
192 configuration runes for that Lisp system,
193 even though they're useless
194 if the system isn't actually installed.
197 .BI "\-c" "\fR, " "\-\-config-file=" conf
198 Read configuration from
202 is a directory, then all of the files within
205 are loaded, in ascending lexicographical order;
209 All of the files are expected to be as described in
210 .BR runlisp.conf (5).
213 .BI "\-d" "\fR, " "\-\-dump-expression=" expr
214 Evaluate the expression(s)
216 and print the resulting value(s)
222 If a form produces multiple values,
223 they are printed on a single line,
224 separated by a single space character;
225 if a form produces no values at all,
226 then nothing is printed \(en not even a newline character.
239 .BI "\-e" "\fR, " "\-\-evaluate-expression=" expr
240 Evaluate the expression(s)
242 and discard the resulting values.
250 .BI "\-l" "\fR, " "\-\-load-file=" file
251 Read and evaluate forms from the
260 .BR "\-n" ", " "\-\-dry-run"
261 Don't actually start the Lisp environment.
262 This may be helpful for the curious,
265 to increase the verbosity.
269 .BR "\-\-no-dry-run" .
272 .BI "\-o" "\fR, " "\-\-set-option=\fR[" sect :\fR] var = value
277 in configuration section
281 if no section is specified.
282 The value is unexpandable,
283 and overrides any similarly named setting
284 from the configuration file(s).
287 .BI "\-p" "\fR, " "\-\-print-expression=" expr
288 Evaluate the expression(s)
290 and print the resulting value(s)
296 If a form produces multiple values,
297 they are printed on a single line,
298 separated by a single space character;
299 if a form produces no values at all,
300 then nothing is printed \(en not even a newline character.
313 .BR "\-q" ", " "\-\-quiet"
314 Don't print warning messages.
315 This option may be repeated:
316 each use reduces verbosity by one step,
320 The default verbosity level is 1,
321 which prints only warning measages.
324 .BR "\-v" ", " "\-\-verbose"
325 Print informational or debugging messages.
326 This option may be repeated:
327 each use increases verbosity by one step,
331 The default verbosity level is 1,
332 which prints only warning measages.
333 Higher verbosity levels print informational and debugging messages.
342 options may only be given on the command-line itself,
346 These options may be given multiple times:
347 they will be processed in the order given.
348 If any of these options is given, then no
353 to load code from files.
357 are still made available to the evaluated forms and loaded files.
362 program behaves as follows.
365 The first thing it does is parse its command line.
366 Options must precede positional arguments,
367 though the boundary may be marked explicitly using
370 If the command line contains any of
378 treats all of its positional arguments as
380 to provide to the given forms and files,
384 otherwise, the first positional argument becomes the
386 name, the remaining ones become
399 option was not given,
401 reads the second line of the script file,
402 and checks to see if it contains the string
404 If so, then the following text is parsed
406 .IR "embedded options" ,
410 The text is split into words
411 separated by sequences of whitespace characters.
413 and other special characters,
414 can be included in a word by
418 Text between single quotes
420 is included literally, without any further interpretation;
421 text between double quotes
423 is treated literally,
424 except that escaping can still be used
425 to escape (e.g.) double quotes and the escape character itself.
426 Outside of single quotes, a backslash
428 causes the following character to be included in a word
429 regardless of its usual meaning.
430 (None of this allows a newline character
431 to be included in a word:
432 this is simply not possible.)
435 before processing quoting and escaping
436 marks the end of embedded options.
437 As a concession to Emacs users,
440 appears at the start of a word
441 before processing quoting and escaping,
442 then everything up to and including the next occurrence of
446 The resulting list of words
447 is processed as if it held further command-line options.
452 options are permitted in embedded option lists:
456 are clearly only useful in interactive use;
461 would just be annoying;
466 would override the user's command-line settings;
467 it's clearly too late to set
473 mode, so it's too late for
481 (This feature allows scripts to provide options even if they use
487 or to provide more than one option,
488 since many operating systems pass the text following
489 the interpreter name on a
491 line as a single argument, without further splitting it at spaces.)
498 then the default configuration files are read:
499 the system configuration from
500 .B @etcdir@/runlisp.conf
502 .BR @etcdir@/runlisp.d/*.conf ,
503 and the user configuration from
506 .BR ~/.config/runlisp.conf :
513 .I "acceptable Lisp implementations"
517 options have been found,
518 then the list of acceptable implementations
519 consists of all of the implementations mentioned in
525 in the order of their first occurrence.
526 (If an implementation is named more than once,
529 prints a warning to stderr
530 and ignores all but the first occurrence.)
533 option is given, then
536 which consists of all of the Lisp implementations
537 defined in its configuration,
538 in the order in which they were defined.
542 .I "preferred Lisp implementations"
544 If the environment variable
547 then its value should be a list of names of Lisp implementations
548 separated by a comma and/or one or more whitespace characters.
549 Otherwise, if there is a setting for the variable
553 configuration section,
554 then its (expanded) value should be a list of Lisp implementations,
556 Otherwise, the list of preferred implementations is empty.
563 mode, then a new command line is built,
564 which invokes an internal script,
565 instructing it to evaluate and print the requested expressions,
566 and load the requested files.
569 Acceptable Lisp implementations are tried in turn.
570 First, the preferred implementations
571 which are also listed as acceptable implementations
572 are tried, in the order in which they appear
573 in the preferred implementations list;
574 then, the remaining acceptable implementations are tried
575 in the order in which they appear
576 in the acceptable implementations list.
579 A Lisp implementation is defined by a configuration section
580 which defines a variable
582 The name of the configuration section
583 is the name of the Lisp implementation,
584 as used in the acceptable and preferred lists described above.
588 is looked up in the configuration section.
589 If a value is found, then
593 and checks to see if a file exists with the resulting name.
594 If so, it sets the variable
598 in the configuration section.
602 is expanded and word-split.
605 (an internal script, in
611 the entire list is passed to the
614 If that succeeds, the Lisp implementation runs;
617 then other Lisp systems are tried;
618 if it fails with some other error, then
620 reports an error message to stderr
621 and exits unsuccessfully
625 option was given, then
627 just simulates the behaviour of
629 printing messages to stderr
630 if the verbosity level is sufficiently high,
633 .SS "Script environment"
634 Many Lisp implementations don't provide a satisfactory environment
635 for scripts to run in.
636 The actual task of invoking a Lisp implementation
637 is left to configuration,
638 but the basic configuration supplied with
640 ensures the following facts about their environment.
652 Most Lisp systems support a user initialization file
653 which they load before entering the REPL;
654 some also have a system initialization file.
660 so that the Lisp environment is reasonably predictable,
661 and to avoid slowing down script startup
662 with things which are convenient for use in an interactive session,
663 but can't be relied upon by a script anyway.
665 The Unix standard input, standard output, and standard error files
666 are available through the Lisp
667 .BR *standard-input* ,
668 .BR *standard-output* ,
671 streams, respectively.
679 .B ext:*require-verbose*
681 Alas, this is insufficient to muffle noise while loading add-on systems
682 on some implementations.
684 If an error is signalled, and not caught by user code,
685 then the process will print a message to stderr
686 and exit with a nonzero status.
687 The reported message may be a long, ugly backtrace,
688 or a terse error report.
689 If no error is signalled but not caught,
690 then the process will exit with status 0.
692 The initial package is
693 .BR COMMON-LISP-USER ,
694 which has no symbols `present' (i.e., imported or interned).
700 systems are already loaded.
701 Further systems can be loaded using
705 (which is only meaningful if
710 and arguments are available through the
713 .B uiop:*command-line-arguments*
714 variable, respectively.
716 .\"--------------------------------------------------------------------------
720 Loading ASDF systems is irritatingly noisy
721 with some Lisp implementations.
722 Suggestions for how to improve this are welcome.
724 More Lisp implementations should be supported.
725 I've supported the ones I have installed.
726 I'm not willing to put a great deal of effort into supporting
727 non-free Lisp implementations;
728 but help supporting free Lisps is much appreciated.
730 The protocol for passing the script name through to
732 (specifically, through the
734 environment variable)
738 is obviously a better approach than introducing a
739 .BR runlisp -specific
740 interface to the same information.
741 I don't know how to fix this:
742 suggestions are welcome.
745 .BR dump-runlisp-image (1),
746 .BR query-runlisp-config (1),
747 .BR runlisp.conf (5).
750 Mark Wooding, <mdw@distorted.org.uk>
752 .\"----- That's all, folks --------------------------------------------------