@@@ more wip
[runlisp] / runlisp.conf.5
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..
42.ds , \h'.16667m'
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.
52.SS "General syntax"
53In summary,
54a configuration file is structured as a collection of assignments
55.I variable
56.B =
57.IR value ,
58gathered into named sections by header lines
59.BI [ section ]\fR.
60.PP
61Comments are indicated by a semicolon
62.RB ` ; '
63in the leftmost column,
64and extend to the end of the line;
65comments and lines consisting only of whiteapace are ignored
66and have no effect whatever.
67Semicolons not in the first column do
68.I not
69introduce comments,
70and have no special meaning.
71.PP
72A
73.I name
74is a non-empty sequence of ASCII alphanumeric characters,
75or the special constituent characters
76.RB ` \- ',
77.RB ` _ ',
78.RB ` . ',
79.RB ` / ',
80.RB ` * ',
81.RB ` + ',
82.RB ` *% ',
83or
84.RB ` @ '.
85For example,
86.RB ` foo ',
87.RB ` 12345 ',
88.RB ` \-2.718 ',
89.RB ` 113/355 ',
90.RB ` image-dir ',
91.RB ` @%IMAGEDIR ',
92and
93.RB ` *organa-solo* '
94are all names, but
95.RB ` foo:bar '
96.RB ` happy? '
97and
98.RB ` $3.95 '
99are not.
100Names beginning with
101.RB ` @ '
102are reserved for use by the
103.B runlisp
104programs;
105names beginning with
106.RB ` % '
107or
108.RB ` @% '
109are by convention private.
110.PP
111A
112.I section header
113is a line of the form
114.IP
115.BI [ section ]
116.PP
117where
118.I section
119is a name, as defined above.
120There may be whitespace before and after the
121.I name
122or after the
123.RB ` ] '.
124Section headers need not have distinct names.
125Subsequent assignments are applied to the section called
126.IR name ,
127up until the next section header, or the end of the file.
128Assignments prior to the first section header in a file
129are applied to the
130.B @CONFIG
131section.
132.PP
133An
134.I assignment
135begins with a line of the form
136.IP
137.I variable
138.B =
139.I rest
140.PP
141where
142.I variable
143is a name, as defined above,
144and it includes all subsequent
145(non-empty, non-comment)
146lines up to, but not including,
147the next line which does
148.I not
149begin with whitespace or a semicolon,
150or the end of the input file.
151There may be space before or after the
152.RB ` = '.
153The
154.I value
155assigned consists of the text of the initial line following the
156.RB ` = '
157character
158(shown as
159.I rest
160above),
161together with the contents of the subsequent lines;
162initial and trailing whitespace is removed from each piece,
163and the (nonempty) pieces are joined,
164separated by single spaces.
165We say that a assignment
166assigns a value to the variable
167in some section \(en
168namely, the section in which the assignment is applied.
169.PP
170For example,
171consider the following file.
172.IP
173.ft B
174.nf
175long =
176 one
177
178 two
179; this line is a comment
180 ; not a comment
181 three
182
183short = just a quick note
184.fi
185.ft P
186.PP
187Then
188.B long
189is assigned the value
190.RB ` "one two ; not a comment three" ',
191and
192.B short is assigned
193.RB ` "just a quick note" '.
194.PP
195The assignments applied to a section
196need not have distinct variable names.
197Only the last assignment to a particular variable name in a section is
198.IR effective ;
199the earlier assignments are simply ignored.
200If an effective assignment assigns a value to a variable in a section,
201we say that the variable is
202.I set
203to that value in the section.
204.
205.SS "Lookup and inheritance"
206A section may have zero or more
207.I parent
208sections.
209.PP
210The
211.BR @BUILTIN ,
212.BR @CONFIG ,
213and
214.B @ENV
215sections have no parents.
216The
217.B @CONFIG
218section has one parent, namely
219.BR @BUILTIN .
220.PP
221If the variable
222.B @parents
223is set in a section other than one of those named above,
224then it must consist of a space- or comma-separated list
225of names,
226which name the section's parents.
227Currently, the parents need not be distinct,
228though duplicates have no effect other than slowing down lookup.
229The order in which parents are listed is not significant.
230If
231.B @parents
232is not set in a section other than one of those named above,
233then by default it has one parent, namely
234.BR @COMMON .
235.PP
236It is currently possible to build a cyclic structure of parent links.
237This is not recommended.
238If lookup (explained below) detects a cycle
239then it will report a fatal error,
240but cycles may exist without being detected.
241.PP
242A variable is
243.I "looked up"
244in a section as follows.
245.hP 1.
246If there is an effective assignment
247of a value to that variable in the section
248then lookup finds that assignment.
249.hP 2.
250If the section has no parents,
251then lookup fails.
252.hP 3.
253Otherwise, the variable is looked up in each of the section's parents.
254If none of these lookups succeeds, then the lookup fails.
255If all of the successful lookups found the
256.I "same assignment"
257(not just the same value!)
258then lookup finds that assignment.
259Otherwise, the lookup reports an error.
260.
261.SS "Expansion and word-splitting"
262A value can be
263.I expanded
264relative to some home section,
265and optionally split into words.
266.PP
267Not all values are
268.IR expandable .
269Values set by assignments in a configuration file are always expandable.
270Values set on the command line \(en in
271.B \-o
272options \(en are not expandable.
273Values in the
274.B @ENV
275section from environment variables (see below) are not expandable.
276Some values set in the
277.B @BUILTIN
278section are expandable and some are not.
279Applying expansion to a value that is not expandable
280simply results in that same value, unchanged.
281.PP
282Applying expansion to an expandable value
283produces a result string as follows.
284The value is scanned from start to end.
285.hP \*o
286A backslash
287.RB ` \e '
288is discarded, but the immediately following character
289is copied to the output without further inspection.
290.hP \*o
291A
292.I variable substitution
293takes the form
294.BR ${ [ \c
295.IB sect : \c
296.RI ] var \c
297.RB [ | \c
298.IR filter ]... \c
299.RB [ ? \c
300.IR alt ] \c
301.BR } .
302A variable named
303.I var
304is looked up in the section named
305.IR sect ,
306or, if omitted, in the home section.
307If the lookup succeeds,
308then the value is expanded,
309processed by the
310.IR filter s
311(explained below),
312and appended to the output.
313If the lookup failed,
314and
315.BI ? alt
316is present,
317then
318.I alt
319is expanded and appended to the output.
320Otherwise,
321if the lookup fails and there is no
322.I alt
323text, then an error is reported.
324.IP
325A filter
326.B u
327causes the expanded value to be converted to uppercase;
328similarly,
329.B l
330causes the expanded value to be converted to lowercase.
331A filter
332.B q
333causes a backslash to be inserted before each
334backslash or double-quote character in the expanded value,
335so that this can be used as part of a quoted Common Lisp string.
336.hP \*o
337A
338.I conditional
339takes the form
340.BR $? [ \c
341.IB sect : \c
342.RI ] var \c
343.BI { conseq \c
344.RB [ | \c
345.IR alt ] \c
346.BR } .
347A variable named
348.I var
349is looked up in the section named
350.IR sect ,
351or, if omitted, in the home section.
352If the lookup succeeds, then
353.I conseq
354is expanded and appended to the output;
355otherwise, if
356.I alt
357is present, then it is expanded and appended to the output;
358otherwise, nothing happens.
359.hP \*o
360A dollar sign which doesn't introduce one of the forms above
361is invalid, and a fatal error is reported.
362.hP \*o
363Any other characters are simply appended to the output.
364.PP
365Word-splitting is similar but more complex.
366The result is not a string, but a sequence of strings.
367At any given point in this procedure,
368there may be a partially constructed word,
369or there might not.
370.hP \*o
371Outside of quotes (see below),
372whitespace serves to separate words.
373When a whitespace character is encountered,
374if there is a word under construction,
375then it is finished and added to the output list;
376otherwise it is simply ignored.
377.hP \*o
378If a backslash is encountered,
379then a word is started if there is none currently under construction,
380and the character following the backslash is added to the current word.
381.hP \*o
382If a single-quote character
383.RB ` ' '
384is encountered,
385then a word is started if there is none currently under construction,
386and
387.I all
388characters up to the next single quote
389are added to the current word.
390This includes double quotes, dollar signs, and backslashes.
391(Neither of the two single quotes is appended to the current word.)
392.hP \*o
393If a double-quote character
394.RB ` """" '
395is encountered,
396then a word is started if there is none currently under construction.
397Until the next double quote is encountered,
398whitespace and single quotes treated literally,
399and simply added to the current word;
400backslashes can be used to escape characters,
401such as double quotes,
402as usual.
403.hP \*o
404If a
405.BR $ -expansion
406\(en a variable substitution or conditional (as described above) \(en
407is encountered
408and there is a current word under construction,
409then the result of the
410.BR $ -expansion
411is appended to the current word.
412If there is no current word,
413then the variable value, or consequent or alternative text,
414is subjected to word splitting in addition to expansion,
415and the resulting words appended to the output sequence.
416.hP \*o
417If any other character is encountered,
418then a word is started if there is none currently under construction,
419and the character is appended to the current word.
420.PP
421One case which deserves attention:
422if a
423.BR $ -expansion
424is encountered outside of a word,
425so that the result is subject to word splitting,
426then an error is reported if a new word is started
427without there being whitespace between the closing brace of the
428.B $ -expansion
429and the character which started the new word.
430For example,
431.IP
432.B "bad = one ${x}two"
433.PP
434would be invalid in a word-splitting context.
435.
436.SS "Predefined variables in @BUILTIN"
437The
438.B @BULITIN
439Section has no parents.
440You should not override its settings in configuration files.
441it holds a number of variables set by the
442.B runlisp
443programs.
444.TP
445.B @data-dir
446The directory in which
447.BR runlisp 's
448auxiliary data files and scripts are located.
449This is determined by the
450.B RUNLISP_DATADIR
451environment variable,
452the
453.B data-dir
454variable in the
455.B @CONFIG
456section,
457or a value determined at compile time.
458.TP
459.B @ecl-opt
460The preferred option prefix for ECL, either
461.RB ` \- '
462or
463.RB ` \-\- '.
464(For some reason,
465the ECL developers are changing
466the way ECL recognizes command-line options,
467because they think that the minor aesthetic improvement
468is worth breaking everyone's scripts.)
469This is determined by the
470.B ecl-opt
471variable in the
472.B @CONFIG
473section,
474or a value determined at compile time.
475.TP
476.B @image-dir
477The directory in which
478.B runlisp
479looks for, and
480.B dump-runlisp-image
481stores, custom Lisp images.
482This is determined by the
483.B RUNLISP_IMAGEDIR
484environment variable,
485the
486.B image-dir
487variable in the
488.B @CONFIG
489section,
490or a value determined at compile time.
491.TP
492.B @image-new
493Set by
494.BR dump-runlisp-image (1)
495to the filename that a
496.B dump-image
497command should create.
498.RB ( dump-runlisp-image
499will rename the image into place itself,
500if the command completes successfully.)
501.TP
502.B @image-out
503Set by
504.BR dump-runlisp-image (1)
505to the filename of the intended output image.
506(Don't use this in
507.B dump-image
508commands: use
509.B @image-new
510instread.)
511.TP
512.B @script
513Set by
514.BR runlisp (1)
515to the name of the script being invoked.
516.TP
517.B @tmp-dir
518Set by
519.BR dump-runlisp-image (1)
520to be the name of a directory in which a
521.B dump-image
522command can put temporary files.
523.
524.SS "Other special variables"
525In every section, the section's name
526is automatically assigned to the variable
527.BR @name .
528This variable
529.I can
530be overridden by an explicit assignment,
531but this is not recommended.
532.
533.\"--------------------------------------------------------------------------
534.
535.SH BUGS
536.hP \*o
537.
538.SH SEE ALSO
539.BR dump-runlisp-image (1),
540.BR query-runlisp-config (1),
541.BR runlisp (1).
542.
543.SH AUTHOR
544Mark Wooding, <mdw@distorted.org.uk>
545.
546.\"----- That's all, folks --------------------------------------------------