runlisp.c: Undefine local option-parsing macros at the end of the block.
[runlisp] / runlisp.conf.5.in
CommitLineData
8996f767
MW
1.\" -*-nroff-*-
2.\"
3.\" Manual for `runlisp' configuration files
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..
eea3b0c7 42.ds .. \&.\|.\|.
8996f767
MW
43.
44.\"--------------------------------------------------------------------------
45.TH runlisp.conf 5 "27 August 2020" "Mark Wooding"
46.SH NAME
47runlisp.conf \- configuration files for runlisp
48.
49.\"--------------------------------------------------------------------------
50.SH DESCRIPTION
51.
10427eb2
MW
52.SS "Default configuration files"
53By default, the
54.B runlisp
55programs read configuration from the following files.
56(Note that if a
57.RB ` \-c '
58command-line option is given, then
59these default files are
60.I not
61read.)
62.TP
63.B @etcdir@/runlisp.d/*.conf
64If a directory named
65.B @etcdir@/runlisp.d
66exists,
67then all of the files within
68whose names end in
69.RB ` .conf '
70are read,
71in ascending lexicographical order by name.
72This directory name can be overridden by setting the
73.B RUNLISP_SYSCONFIG_DIR
74environment variable.
75.TP
76.B @etcdir@/runlisp.conf
77The file named
78.B @etcdir@/runlisp.conf
79is read; the file must exist.
80This filename can be overridden by setting the
81.B RUNLISP_SYSCONFIG
82environment variable.
83.TP
84.B ~/.runlisp.conf
85If there is a file named
86.B .runlisp.conf
87in the user's home directory,
88then it is read.
89The home directory is determined to be
90the value of the
91.B HOME
92environment variable, or, if that is not set,
93the home directory associated with the process's real uid
94in the system password database.
95This filename can be overridden by setting the
96.B RUNLISP_USERCONFIG
97environment variable.
98.TP
99.B ~/.config/runlisp.conf
100If there is a file named
101.B runlisp.conf
102in the user's XDG configuration directory,
103then it is read.
104The XDG configuration directory is determined to be the value of the
105.B XDG_CONFIG_HOME
106environment variable, or the
107.B .config
108directory in the user's home directory
109(as determined above).
110This filename can be overridden by setting the
111.B RUNLISP_USERCONFIG
112environment variable.
113(Note, therefore, that this variable overrides
114.I both
115of the user configuration files.)
116.
8996f767
MW
117.SS "General syntax"
118In summary,
119a configuration file is structured as a collection of assignments
120.I variable
121.B =
122.IR value ,
123gathered into named sections by header lines
124.BI [ section ]\fR.
125.PP
126Comments are indicated by a semicolon
127.RB ` ; '
128in the leftmost column,
129and extend to the end of the line;
130comments and lines consisting only of whiteapace are ignored
131and have no effect whatever.
132Semicolons not in the first column do
133.I not
134introduce comments,
135and have no special meaning.
136.PP
137A
138.I name
139is a non-empty sequence of ASCII alphanumeric characters,
140or the special constituent characters
141.RB ` \- ',
142.RB ` _ ',
143.RB ` . ',
144.RB ` / ',
145.RB ` * ',
146.RB ` + ',
147.RB ` *% ',
148or
149.RB ` @ '.
150For example,
151.RB ` foo ',
152.RB ` 12345 ',
153.RB ` \-2.718 ',
154.RB ` 113/355 ',
155.RB ` image-dir ',
156.RB ` @%IMAGEDIR ',
157and
158.RB ` *organa-solo* '
159are all names, but
160.RB ` foo:bar '
161.RB ` happy? '
162and
163.RB ` $3.95 '
164are not.
165Names beginning with
166.RB ` @ '
167are reserved for use by the
168.B runlisp
169programs;
170names beginning with
171.RB ` % '
172or
173.RB ` @% '
174are by convention private.
175.PP
176A
177.I section header
178is a line of the form
179.IP
180.BI [ section ]
181.PP
182where
183.I section
184is a name, as defined above.
185There may be whitespace before and after the
186.I name
187or after the
188.RB ` ] '.
189Section headers need not have distinct names.
190Subsequent assignments are applied to the section called
191.IR name ,
192up until the next section header, or the end of the file.
193Assignments prior to the first section header in a file
194are applied to the
195.B @CONFIG
196section.
197.PP
198An
199.I assignment
200begins with a line of the form
201.IP
202.I variable
203.B =
204.I rest
205.PP
206where
207.I variable
208is a name, as defined above,
209and it includes all subsequent
210(non-empty, non-comment)
211lines up to, but not including,
212the next line which does
213.I not
214begin with whitespace or a semicolon,
215or the end of the input file.
216There may be space before or after the
217.RB ` = '.
218The
219.I value
220assigned consists of the text of the initial line following the
221.RB ` = '
222character
223(shown as
224.I rest
225above),
226together with the contents of the subsequent lines;
227initial and trailing whitespace is removed from each piece,
228and the (nonempty) pieces are joined,
229separated by single spaces.
f8174852 230We say that an assignment
8996f767
MW
231assigns a value to the variable
232in some section \(en
233namely, the section in which the assignment is applied.
234.PP
235For example,
236consider the following file.
237.IP
238.ft B
239.nf
240long =
241 one
242
243 two
244; this line is a comment
245 ; not a comment
246 three
247
248short = just a quick note
249.fi
250.ft P
251.PP
252Then
253.B long
254is assigned the value
255.RB ` "one two ; not a comment three" ',
256and
257.B short is assigned
258.RB ` "just a quick note" '.
259.PP
260The assignments applied to a section
261need not have distinct variable names.
262Only the last assignment to a particular variable name in a section is
263.IR effective ;
264the earlier assignments are simply ignored.
265If an effective assignment assigns a value to a variable in a section,
266we say that the variable is
267.I set
268to that value in the section.
269.
270.SS "Lookup and inheritance"
271A section may have zero or more
272.I parent
273sections.
274.PP
275The
10427eb2 276.B @BUILTIN
8996f767
MW
277and
278.B @ENV
279sections have no parents.
280The
281.B @CONFIG
282section has one parent, namely
283.BR @BUILTIN .
284.PP
285If the variable
286.B @parents
287is set in a section other than one of those named above,
288then it must consist of a space- or comma-separated list
289of names,
290which name the section's parents.
291Currently, the parents need not be distinct,
292though duplicates have no effect other than slowing down lookup.
293The order in which parents are listed is not significant.
294If
295.B @parents
296is not set in a section other than one of those named above,
297then by default it has one parent, namely
298.BR @COMMON .
299.PP
300It is currently possible to build a cyclic structure of parent links.
301This is not recommended.
302If lookup (explained below) detects a cycle
303then it will report a fatal error,
304but cycles may exist without being detected.
305.PP
306A variable is
307.I "looked up"
308in a section as follows.
309.hP 1.
310If there is an effective assignment
311of a value to that variable in the section
312then lookup finds that assignment.
313.hP 2.
314If the section has no parents,
315then lookup fails.
316.hP 3.
317Otherwise, the variable is looked up in each of the section's parents.
318If none of these lookups succeeds, then the lookup fails.
319If all of the successful lookups found the
320.I "same assignment"
321(not just the same value!)
322then lookup finds that assignment.
323Otherwise, the lookup reports an error.
324.
325.SS "Expansion and word-splitting"
326A value can be
327.I expanded
328relative to some home section,
329and optionally split into words.
330.PP
331Not all values are
332.IR expandable .
333Values set by assignments in a configuration file are always expandable.
334Values set on the command line \(en in
335.B \-o
336options \(en are not expandable.
337Values in the
338.B @ENV
339section from environment variables (see below) are not expandable.
340Some values set in the
341.B @BUILTIN
342section are expandable and some are not.
343Applying expansion to a value that is not expandable
344simply results in that same value, unchanged.
345.PP
346Applying expansion to an expandable value
347produces a result string as follows.
348The value is scanned from start to end.
349.hP \*o
350A backslash
351.RB ` \e '
352is discarded, but the immediately following character
353is copied to the output without further inspection.
354.hP \*o
355A
356.I variable substitution
357takes the form
358.BR ${ [ \c
359.IB sect : \c
360.RI ] var \c
361.RB [ | \c
eea3b0c7 362.IR filter ]\*(.. \c
8996f767
MW
363.RB [ ? \c
364.IR alt ] \c
365.BR } .
366A variable named
367.I var
368is looked up in the section named
369.IR sect ,
370or, if omitted, in the home section.
371If the lookup succeeds,
372then the value is expanded,
373processed by the
374.IR filter s
375(explained below),
376and appended to the output.
377If the lookup failed,
378and
379.BI ? alt
380is present,
381then
382.I alt
383is expanded and appended to the output.
384Otherwise,
385if the lookup fails and there is no
386.I alt
387text, then an error is reported.
388.IP
389A filter
390.B u
391causes the expanded value to be converted to uppercase;
392similarly,
393.B l
394causes the expanded value to be converted to lowercase.
395A filter
396.B q
397causes a backslash to be inserted before each
398backslash or double-quote character in the expanded value,
399so that this can be used as part of a quoted Common Lisp string.
400.hP \*o
401A
402.I conditional
403takes the form
404.BR $? [ \c
405.IB sect : \c
406.RI ] var \c
407.BI { conseq \c
408.RB [ | \c
409.IR alt ] \c
410.BR } .
411A variable named
412.I var
413is looked up in the section named
414.IR sect ,
415or, if omitted, in the home section.
416If the lookup succeeds, then
417.I conseq
418is expanded and appended to the output;
419otherwise, if
420.I alt
421is present, then it is expanded and appended to the output;
422otherwise, nothing happens.
423.hP \*o
424A dollar sign which doesn't introduce one of the forms above
425is invalid, and a fatal error is reported.
426.hP \*o
427Any other characters are simply appended to the output.
428.PP
429Word-splitting is similar but more complex.
430The result is not a string, but a sequence of strings.
431At any given point in this procedure,
432there may be a partially constructed word,
433or there might not.
434.hP \*o
435Outside of quotes (see below),
436whitespace serves to separate words.
437When a whitespace character is encountered,
438if there is a word under construction,
439then it is finished and added to the output list;
440otherwise it is simply ignored.
441.hP \*o
442If a backslash is encountered,
443then a word is started if there is none currently under construction,
444and the character following the backslash is added to the current word.
445.hP \*o
446If a single-quote character
447.RB ` ' '
448is encountered,
449then a word is started if there is none currently under construction,
450and
451.I all
452characters up to the next single quote
453are added to the current word.
454This includes double quotes, dollar signs, and backslashes.
455(Neither of the two single quotes is appended to the current word.)
456.hP \*o
457If a double-quote character
458.RB ` """" '
459is encountered,
460then a word is started if there is none currently under construction.
461Until the next double quote is encountered,
462whitespace and single quotes treated literally,
463and simply added to the current word;
464backslashes can be used to escape characters,
465such as double quotes,
466as usual.
467.hP \*o
468If a
469.BR $ -expansion
470\(en a variable substitution or conditional (as described above) \(en
471is encountered
472and there is a current word under construction,
473then the result of the
474.BR $ -expansion
475is appended to the current word.
476If there is no current word,
477then the variable value, or consequent or alternative text,
478is subjected to word splitting in addition to expansion,
479and the resulting words appended to the output sequence.
480.hP \*o
481If any other character is encountered,
482then a word is started if there is none currently under construction,
483and the character is appended to the current word.
484.PP
485One case which deserves attention:
486if a
487.BR $ -expansion
488is encountered outside of a word,
489so that the result is subject to word splitting,
490then an error is reported if a new word is started
491without there being whitespace between the closing brace of the
492.B $ -expansion
493and the character which started the new word.
494For example,
495.IP
496.B "bad = one ${x}two"
497.PP
498would be invalid in a word-splitting context.
499.
10427eb2
MW
500.SS "Other special variables"
501In every section, the section's name
502is automatically assigned to the variable
503.BR @name .
504This variable
505.I can
506be overridden by an explicit assignment,
507but this is not recommended.
508.
8996f767
MW
509.SS "Predefined variables in @BUILTIN"
510The
511.B @BULITIN
512Section has no parents.
513You should not override its settings in configuration files.
514it holds a number of variables set by the
515.B runlisp
516programs.
10427eb2 517.
8996f767
MW
518.TP
519.B @data-dir
520The directory in which
521.BR runlisp 's
522auxiliary data files and scripts are located.
523This is determined by the
524.B RUNLISP_DATADIR
525environment variable,
526the
527.B data-dir
528variable in the
529.B @CONFIG
530section,
531or a value determined at compile time.
10427eb2 532.
8996f767
MW
533.TP
534.B @ecl-opt
535The preferred option prefix for ECL, either
536.RB ` \- '
537or
538.RB ` \-\- '.
539(For some reason,
540the ECL developers are changing
541the way ECL recognizes command-line options,
542because they think that the minor aesthetic improvement
543is worth breaking everyone's scripts.)
544This is determined by the
545.B ecl-opt
546variable in the
547.B @CONFIG
548section,
549or a value determined at compile time.
10427eb2 550.
8996f767 551.TP
c7af83cd
MW
552.B @hash
553Set by
554.BR dump-runlisp-image (1)
555to the hash
556(a string of hexadecimal digits)
557identifying the versions of the Lisp code included
558\(en or to be included \(en
559in a custom image.
560This is constructed by hashing the result of evaluating the
561.B lisp-version
562expression in the system definition.
563.
564.TP
8996f767
MW
565.B @image-dir
566The directory in which
567.B runlisp
568looks for, and
569.B dump-runlisp-image
570stores, custom Lisp images.
571This is determined by the
572.B RUNLISP_IMAGEDIR
573environment variable,
574the
575.B image-dir
576variable in the
577.B @CONFIG
578section,
579or a value determined at compile time.
10427eb2 580.
8996f767 581.TP
c7af83cd
MW
582.B @image-link
583The well-known name of the image;
584actually a symbolic link to the `real' image file,
585whose name includes a hash
586which identifies the versions of the Lisp code included in the image.
587.
588.TP
8996f767
MW
589.B @image-new
590Set by
591.BR dump-runlisp-image (1)
592to the filename that a
593.B dump-image
594command should create.
595.RB ( dump-runlisp-image
596will rename the image into place itself,
597if the command completes successfully.)
10427eb2 598.
8996f767 599.TP
c7af83cd
MW
600.B @image-newlink
601Set by
602.BR dump-runlisp-image (1)
603to the name to use for the updated symbolic link to the image file.
604This is used internally,
605and is not expected to be useful in Lisp system definitions.
606.
607.TP
8996f767
MW
608.B @image-out
609Set by
610.BR dump-runlisp-image (1)
611to the filename of the intended output image.
612(Don't use this in
613.B dump-image
614commands: use
615.B @image-new
616instread.)
10427eb2 617.
8996f767
MW
618.TP
619.B @script
620Set by
621.BR runlisp (1)
622to the name of the script being invoked.
10427eb2 623.
8996f767
MW
624.TP
625.B @tmp-dir
626Set by
627.BR dump-runlisp-image (1)
628to be the name of a directory in which a
629.B dump-image
630command can put temporary files.
631.
10427eb2
MW
632.SS "Environment variables in @ENV"
633The
634.B @ENV
635section is special,
636and is used to hold a copy of the system environment.
637At startup,
638it contains an assignment for every environment variable.
639The
640.B @ENV
641section has no parents.
642The values are not expandable.
643It is possible to override
644.B @ENV
645settings in configuration files
646or on the command line,
8996f767
MW
647but this is not recommended.
648.
10427eb2
MW
649.SS "The @COMMON section"
650The
651.B @COMMON section
652is the default parent for nearly all other configuration sections
653(the exceptions being
654.B @BUILTIN
655and
656.BR @ENV ,
657which have no parents, and
658.B @COMMON
659itself, whose parent is
660.BR @BUILTIN ).
661It is used in the provided configuration
662to hold various common snippets of Lisp code and other settings,
663but the
664.B runlisp
665programs themselves make no direct use of it.
8996f767 666.
10427eb2
MW
667.SS "Overall configuration in @CONFIG"
668Variable settings in
669.B @CONFIG
670are consulted for various administrative reasons.
671.PP
672Because of the open-ended nature of this configuration mechanism,
673users can easily invent new configuration variables
674for any purpose they can imagine.
675The following variables are used by the
676.B runlisp
677programs directly, or its default configuration.
678All values are expanded before use;
679the
680.B @CONFIG
681section's parent is
682.BR @COMMON ,
683as usual.
684.
685.TP
686.B data-dir
687The directory in which
688.BR runlisp 's
689auxiliary data files and scripts are located.
690There is a hardcoded default
691determined at compile-time,
692which is probably correct.
693Overridden by the
694.B RUNLISP_DATADIR
695environment variable.
696Don't refer to this setting directly:
697expand
698.B @data-dir
699from the
700.B @BUILTIN
701section instead.
702.
703.TP
704.B dump
705A comma-separated list of Lisp implementation names
706which should have custom images dumped by
707.BR "dump-runlisp-image \-a" .
708The order is not especially significant.
709The default is all of the configured implementations
710which define a
711.B dump-image
712variable
713and whose command can be found.
714.
715.TP
716.B ecl-opt
717The preferred option prefix for ECL, either
718.RB ` \- '
719or
720.RB ` \-\- '.
721There is a hardcoded default
722determined at compile-time,
723which was correct for the system on which
724.B runlisp
725was built.
726Don't refer to this setting directly:
727expand
728.B @ecl-opt
729from the
730.B @BUILTIN
731section instead.
732.
733.TP
734.B @image-dir
735The directory in which
736.B runlisp
737looks for, and
738.B dump-runlisp-image
739stores, custom Lisp images.
740Overridden by the
741.B RUNLISP_IMAGEDIR
742environment variable.
743Don't refer to this setting directly:
744expand
745.B @image-dir
746from the
747.B @BUILTIN
748section instead.
749.
750.TP
751.B prefer
752A comma-separated list of names of
753.I preferred
754Lisp implementations,
755Overridden by the
756.B RUNLISP_PREFER
757environment variable.
758.
759.SS "Lisp implementation definitions"
760A Lisp implementation is described to
761.B runlisp
762by a configuration section.
763The section's name is used to refer to the implementation,
764e.g., in
765.BR runlisp 's
766.B \-L
767option,
768or in the
769.B dump
770and
771.B prefer
772lists described above.
773.PP
774The following variable settings are used directly;
775of course, a Lisp implementation definition may contain other settings
776for internal purposes.
777.
778.TP
779.B command
780The name of the program used to invoke the Lisp implementation.
781.BR dump-runlisp-image
782looks to see whether this program is installed when invoked with the
783.B \-i
784option:
785it will fail if there is no
786.B command
787setting.
788It is also commonly
789(but not universally)
790used in the
791.B run-script
792and
793.B dump-image
794variables.
795It's conventional to set this to
796.B ${@ENV:FOO?foo}
797so that the command name can be overridden from the environment.
798.
799.TP
800.B dump-image
801The complete command to use to dump a custom image
802for this Lisp implementation.
803The value is subjected to expansion and word-splitting before use.
804It should write the newly created image to the file named by the
805.B @image-new
806setting in the
807.B @BUILTIN
808section.
809.
810.TP
811.B image-file
812The basename of the custom image file
813(i.e., not containing any
814.BR ` / '
815characters)
816to use when invoking this Lisp implementation.
817.BR runlisp (1)
818and
819.BR dump-runlisp-image (1)
820use the presence of this setting to decide
821whether the implementation supports custom images.
822.
823.TP
824.B image-path
825The complete (but not necessarily absolute) pathname
826of the custom image file for this Lisp implementation.
827It is the (expanded) value of this variable
828which is used by
829.BR runlisp (1)
830when it checks whether a custom image exists.
831It's set to
832.B ${@image-dir}/${image-file}
833in the standard configuration file's
834.B @COMMON
835section,
836and there is probably no need to override it;
837.B @image-dir
838is set in the
839.B @BUILTIN
840section
841.RB ( @image-dir
842is set in the
843.N @BUILTIN
844section \(en see above \(en and
845.B image-file
846must be set in this section
847(or one of its ancestors)
848before
849.BR runlisp (1)
850would not attempt to check for an image file.
851.
852.TP
853.B run-script
854The complete command to use
855to get this Lisp implementation to execute a script.
856The value is subjected to expansion and word-splitting before use.
857The script name is available as
858.B @script
859in the
860.B @BUILTIN
861section \(en see above.
862If a custom image is available, then
863.B @image
864is defined
865(to the value
866.BR t )
867.I "in this section"
868(not in
869.BR @BUILTIN );
870the full path to the image file to use is given by
871.B ${image-path}
872\(en see above.
873.
874.\"--------------------------------------------------------------------------
8996f767
MW
875.
876.SH SEE ALSO
877.BR dump-runlisp-image (1),
878.BR query-runlisp-config (1),
879.BR runlisp (1).
880.
881.SH AUTHOR
882Mark Wooding, <mdw@distorted.org.uk>
883.
884.\"----- That's all, folks --------------------------------------------------