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 .\"--------------------------------------------------------------------------
56 .IB sys , sys , \fR...]
58 .IB sys , sys , \fR...]
72 .\"--------------------------------------------------------------------------
77 program has two main functions.
79 It can be used in a script's
81 line to run a Common Lisp script.
83 It can be used in build scripts
84 to invoke a Common Lisp system,
85 e.g., to build a standalone program.
87 .SS "Supported Common Lisp implementations"
88 The following Lisp implementations are currently supported.
91 Armed Bear Common Lisp.
100 Carnegie\(enMellon University Common Lisp.
103 Embeddable Common Lisp.
106 Steel Bank Common Lisp.
110 program expects, by default,
111 to be able to run a Lisp system
112 as a program with the same name,
113 found by searching as directed by the
115 environment variable.
116 This can be overridden by setting an environment variable,
117 with the same name but in
119 to the actual name \(en
120 either a bare filename to be searched for on the
122 or a pathname containing a
124 relative to the working directory or absolute,
126 Note that the entire variable value is used as the program name:
127 it's not possible to provide custom arguments to a Lisp system
128 using this mechanism.
129 If you want to do that,
130 you must write a shell script to do the necessary work,
131 and point the environment variable
137 Options are read from the command line, as usual,
138 but also from a number of other sources;
144 and the script's second line contains a
147 then text following the marker is parsed as options.
152 .B ~/.config/runlisprc
154 then their contents are parsed as options.
156 If an environment variable
159 then its contents is parsed as options.
161 A simple quoting and escaping system is implemented
162 to allow spaces and other special characters
163 to be included in argument words
164 in the script, configuration files, and environment variable.
165 The details of all of this are given in the section
170 The options accepted are as follows.
177 and a description of the command-line options
179 and immediately exit with status 0.
187 and immediately exit with status 0.
191 Clear the list of preferred Lisp implementations.
195 Don't check for a custom Lisp image.
198 tries to start Lisp systems using a custom image,
199 so that they'll start more quickly;
202 option forces the use of the default `vanilla' image
203 provided with the system.
204 There's not usually any good reason to prefer the vanilla image,
205 except for performance comparisons, or debugging
211 Don't read embedded options from the
215 This has no effect in eval mode.
221 for custom Lisp images.
222 This option overrides the default image directory,
223 which is set at compile time.
226 .BI "\-L " sys , sys ,\fR...
227 Use one of the named Lisp systems.
230 must name a supported Lisp system.
231 This option may be given more than once:
232 the effect is the same as a single option
233 listing all of the systems named, in the same order.
234 If a system is named more than once,
235 a warning is issued (at verbosity level 1 or higher),
236 and all but the first occurrence is ignored.
239 .BI "\-P " sys , sys ,\fR...
240 Set the relative preference order of Lisp systems:
241 systems listed earlier are more preferred.
244 must name a supported Lisp system.
245 This option may be given more than once:
246 the effect is the same as a single option
247 listing all of the systems named, in the same order.
248 If a system is named more than once,
249 a warning is issued (at verbosity level 1 or higher),
250 and all but the first occurrence is ignored.
251 Unmentioned systems are assigned lowest preference:
255 then this provides a default preference ordering;
256 otherwise, an ordering hardcoded into the program is used.
257 The first acceptable Lisp system,
258 according to the preference order just described,
259 which actually exists,
264 Evaluate the expression(s)
266 and discard the resulting values.
275 Read and evaluate forms from the
285 Don't actually start the Lisp environment.
286 This may be helpful for the curious,
289 to increase the verbosity.
293 Evaluate the expression(s)
295 and print the resulting value(s)
299 If a form produces multiple values,
300 they are printed on a single line,
301 separated by a single space character;
302 if a form produces no values at all,
303 then nothing is printed \(en not even a newline character.
312 Don't print warning messages.
313 This option may be repeated:
314 each use reduces verbosity by one step,
318 The default verbosity level is 1,
319 which prints only warning measages.
323 Print informational or debugging messages.
324 This option may be repeated:
325 each use increases verbosity by one step,
329 The default verbosity level is 1,
330 which prints only warning measages.
331 Higher verbosity levels print informational and debugging messages.
339 options may only be given on the command-line itself,
343 in a configuration file,
346 environment variable.
347 These options may be given multiple times:
348 they will be processed in the order given.
349 If any of these options is given, then no
354 to load code from files.
358 are still made available to the evaluated forms and loaded files.
363 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
377 treats all of its positional arguments as
379 to provide to the given forms and files,
383 otherwise, the first positional argument becomes the
385 name, the remaining ones become
397 reads the second line of the script file,
398 and checks to see if it contains the string
400 If so, then the following text is parsed
402 .IR "embedded options" ,
404 The text is split into words
405 separated by sequences of whitespace characters.
407 and other special characters,
408 can be included in a word by
412 Text between single quotes
414 is included literally, without any further interpretation;
415 text between double quotes
417 is treated literally,
418 except that escaping can still be used
419 to escape (e.g.) double quotes and the escape character itself.
420 Outside of single quotes, a backslash
422 causes the following character to be included in a word
423 regardless of its usual meaning.
424 (None of this allows a newline character
425 to be included in a word:
426 this is simply not possible.)
429 before processing quoting and escaping
430 marks the end of embedded options.
431 As a concession to Emacs users,
434 appears at the start of a word
435 before processing quoting and escaping,
436 then everything up to and including the next occurrence of
439 The resulting list of words
440 is processed as if it held further command-line options.
450 options may not appear in a script file's embedded options list.
451 (This feature allows scripts to provide options even if they use
457 or to provide more than one option,
458 since many operating systems pass the text following
459 the interpreter name on a
461 line as a single argument, without further splitting it at spaces.)
465 exists in the user's home directory,
466 then this file is read to discover more options.
469 is set in the environment,
470 then its value is assumed to name the user's home directory;
471 otherwise, the home directory is determined by looking up
472 the process's real uid in the password database.)
473 Lines consisting entirely of whitespace,
474 and lines whose first whitespace character is either
478 are ignored in this file.
479 Other lines are split into words,
480 and processed as additional command-line options,
481 as described for embedded options above,
485 marker does not terminate word splitting; and
487 .RB ` \-*\- ... \-*\- '
488 local variable lists are not ignored.
489 Each line is processed separately,
490 so an option and its argument must be written on the same line.
493 will have committed to
503 options may not appear in a configuration file.
508 .I "configuration home"
510 then it is processed as for
515 is set in the environment,
516 then its value is assumed to name the configuration home;
517 otherwise, the configuration home is the directory
519 in the user's home directory, as determined above.
523 is set in the environment,
524 then its value is split into words
525 and processed as additional command-line options,
526 as for a line of a configuration file as described above.
529 .I "acceptable Lisp implementations"
533 options have been issued,
534 then the list of acceptable implementations
535 consists of all of the implementations mentioned in
541 in the order of their first occurrence.
542 (If an implementation is named more than once,
545 prints a warning to stderr
546 and ignores all but the first occurrence.)
549 option is given, then
552 which consists of all of the supported Lisp implementations
553 in an hardcoded order which reflects
554 the author's arbitrary preferences.
557 .I "preferred Lisp implementations"
561 options have been issued
565 then the list of preferred implementations
566 consists of all of the implementations mentioned in
568 options after the last occurrence of
570 in the order of their first occurrences.
571 (If an implementation is named more than once,
574 prints a warning to stderr
575 and ignores all but the first occurrence.)
581 option appears after all of the
584 then the list of preferred implementations is empty.
586 Acceptable Lisp implementations are tried in turn.
587 First, the preferred implementations
588 which are also listed as acceptable implementations
589 are tried, in the order in which they appear
590 in the preferred implementations list;
591 then, the remaining acceptable implementations are tried
592 in the order in which they appear
593 in the acceptable implementations list.
596 a Lisp implementation means to construct a command line
597 (whose effect will be described below)
601 If that succeeds, the Lisp implementation runs;
604 then other Lisp systems are tried;
605 if it fails with some other error, then
607 reports an error message to stderr
608 and exits unsuccessfully
612 option was given, then
614 just simulates the behaviour of
616 printing messages to stderr
617 if the verbosity level is sufficiently high,
623 the script is invoked.
627 the instructions given in
632 options are carried out,
633 in the order in which the appeared in the command line.
634 The details of the environment
635 in which Lisp code is executed
638 .SS "Script environment"
639 Code in scripts and forms invoked by
641 may assume the following facts about their environment.
653 Most Lisp systems support a user initialization file
654 which they load before entering the REPL;
655 some also have a system initialization file.
661 so that the Lisp environment is reasonably predictable,
662 and to avoid slowing down script startup
663 with things which are convenient for use in an interactive session,
664 but can't be relied upon by a script anyway.
666 The Unix standard input, standard output, and standard error files
667 are available through the Lisp
668 .BR *standard-input* ,
669 .BR *standard-output* ,
672 streams, respectively.
680 .B ext:*require-verbose*
682 Alas, this is insufficient to muffle noise while loading add-on systems
683 on some implementations.
685 If an error is signalled, and not caught by user code,
686 then the process will print a message to stderr
687 and exit with a nonzero status.
688 The reported message may be a long, ugly backtrace,
689 or a terse error report.
690 If no error is signalled but not caught,
691 then the process will exit with status 0.
693 The initial package is
694 .BR COMMON-LISP-USER ,
695 which has no symbols `present' (i.e., imported or interned).
701 systems are already loaded.
702 Further systems can be loaded using
706 (which is only meaningful if
711 and arguments are available through the
714 .B uiop:*command-line-arguments*
715 variable, respectively.
717 .\"--------------------------------------------------------------------------
721 Loading ASDF systems is irritatingly noisy
722 with some Lisp implementations.
723 Suggestions for how to improve this are welcome.
725 More Lisp implementations should be supported.
726 I've supported the ones I have installed.
727 I'm not willing to put a great deal of effort into supporting
728 non-free Lisp implementations;
729 but help supporting free Lisps is much appreciated.
731 The protocol for passing the script name through to
733 (specifically, through the
735 environment variable)
739 is obviously a better approach than introducing a
740 .BR runlisp -specific
741 interface to the same information.
742 I don't know how to fix this:
743 suggestions are welcome.
746 .BR dump-runlisp-image (1).
749 Mark Wooding, <mdw@distorted.org.uk>
751 .\"----- That's all, folks --------------------------------------------------