Remove unnecessary assumptions about structure layouts. (The `pkhead'
[sw-tools] / sw-env.5
CommitLineData
e45f5509 1.\" -*-nroff-*-
2.\"
f73dea54 3.\" $Id: sw-env.5,v 1.3 1999/07/30 18:44:32 mdw Exp $
e45f5509 4.\"
5.\" Manual page for `sw-env' files
6.\"
7.\" (c) 1999 EBI
8.\"
be07bee0 9.
e45f5509 10.\"----- Licensing notice ---------------------------------------------------
11.\"
12.\" This file is part of sw-tools.
13.\"
14.\" sw-tools is free software; you can redistribute it and/or modify
15.\" it under the terms of the GNU General Public License as published by
16.\" the Free Software Foundation; either version 2 of the License, or
17.\" (at your option) any later version.
18.\"
19.\" sw-tools is distributed in the hope that it will be useful,
20.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
21.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22.\" GNU General Public License for more details.
23.\"
24.\" You should have received a copy of the GNU General Public License
25.\" along with sw-tools; if not, write to the Free Software Foundation,
26.\" Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
be07bee0 27.
e45f5509 28.\"----- Revision history ---------------------------------------------------
29.\"
30.\" $Log: sw-env.5,v $
f73dea54 31.\" Revision 1.3 1999/07/30 18:44:32 mdw
32.\" Improve cross-references and tidy up formatting.
33.\"
be07bee0 34.\" Revision 1.2 1999/07/16 12:45:37 mdw
35.\" Internal formatting improvements.
36.\"
e45f5509 37.\" Revision 1.1 1999/06/04 13:56:18 mdw
38.\" New manual page.
39.\"
be07bee0 40.
e45f5509 41.\" --- Useful macro definitions ---
be07bee0 42.
e45f5509 43.de VS \" Start a sort-of verbatim block
44.sp 1
45.in +5n
46.nf
47.ft B
48..
49.de VE \" Stop a sort-of verbatim block
50.ft R
51.fi
52.in -5n
53.sp 1
54..
be07bee0 55.de hP \" Start an indented paragraph with a bold right-aligned label
e45f5509 56.IP
57\fB\h'-\w'\\$1\ 'u'\\$1\ \fP\c
58..
59.\"
60.\" --- Style hacking ---
61.\"
62.ie \n(.g \{\
be07bee0 63. fam P
64. ds mw \fR[\f(BImdw\fR]
e45f5509 65.\}
be07bee0 66.el .ds mw \fR[\fBmdw\fR]
67.ie t .ds o \(bu
68.el .ds o o
e45f5509 69.ds sw \fBsw\fP
70.ds se \fBsw\-env\fP
be07bee0 71.
72.\"----- Main manual text ---------------------------------------------------
73.
f73dea54 74.TH sw-env 5 "25 May 1999" sw-tools
e45f5509 75.PD 1
be07bee0 76.
77.\"--------------------------------------------------------------------------
78.
e45f5509 79.SH NAME
be07bee0 80.
e45f5509 81sw\-env \- environment variable assignment files for \*(sw.
be07bee0 82.
83.\"--------------------------------------------------------------------------
84.
f73dea54 85.SH "DESCRIPTION"
be07bee0 86.
e45f5509 87A \*(se file is a sequence of statements. The following statements are
88supported:
89.sp 1
90.in +5n
91.B :
92.I value
93.RB [ ; ]
94.br
95.B include
96.I value
97.RB [ ; ]
98.br
99.B arch
100.I value
101.B {
102.IR statement ...
103.B }
104.RB [ ; ]
105.br
106.RB [ set ]
107.I name
108.RB [ = ]
109.I value
110.RB [ ; ]
111.br
112.B unset
113.I name
114.RB [ ; ]
115.in -5n
116.sp 1
117Whitespace serves to separate tokens but is otherwise ignored except
118when it occurs quoted within a
119.IR value .
120The file may also contain comments, which begin with a
121.RB ` # '
122character and extend to the end of the line. The start of a comment
123must appear where a new statement is expected. Apart from its behaviour
124of terminating comments, newlines behave the same way as other
125whitespace characters. Keywords are not reserved words.
126.PP
127A
128.I name
129is a sequence of digits, letters and underscores which does not start
130with a digit.
131.PP
132A
133.I value
134may contain any non-null character, although some characters are special
135and must be quoted. The syntax of
136.IR value s
137is loosely based on the Bourne
138shell, although there are differences and irregularities due to the
139quick and dirty nature of the parser. The various quoting and
140substitution operations are described below.
be07bee0 141.
e45f5509 142.SS "Statements"
be07bee0 143.
e45f5509 144The statements behave as follows:
145.TP
146.B :
147The following
148.I value
149is read and discarded. This is not useless: reading a
150.I value
151may cause variables to be assigned as a result of
152`\c
153.BI ${ name = value }\c
154\&' substitutions.
155.TP
156.B include
157A
158.I value
159is read, and further assignments are read from the file so named, if it
160exists. Conventionally, the last statement in the global \*(se file is
161.VS
162include ".sw-env";
163.VE
164to read in package-specific settings.
165.TP
166.B arch
167The following
168.I value
169is read. If it matches the name of the host's architecture, then the
170brace-enclosed statements are executed; otherwise they're ignored. It's
171possible, though not useful, to nest
172.B arch
173statements.
174.TP
175.B set
176A
177.I name
178and
179.I value
180are read, optionally separated by an
181.RB ` = '
182character. The variable named is assigned the value, replacing any
183previously assigned value, if any. The
184.RB ` set '
185keyword is optional. It's only useful so that you can assign values to
186variables whose names are also statement keywords.
187.TP
188.B unset
189A
190.I name
191is read. Any value assigned to the variable named is discarded, and the
192variable is forgotten.
be07bee0 193.
e45f5509 194.SS "Value syntax"
be07bee0 195.
e45f5509 196The parser usually reads a
197.I value
198a character by character, until it finds a delimiter. Delimiter
199characters are
200.RB ` ( ',
201.RB ` ) ',
202.RB ` { ',
203.RB ` } ',
204and
205.RB ` ; ';
206whitespace also acts as a delimiter. Delimiter characters can only
207appear in a value if quoted.
208.PP
209There are three types of quoting understood by the value reader. A
210backslash
211.RB (` \e ')
212character causes the following character to be stripped of its special
213meaning. Hence
214.RB ` \e\e '
215inserts a literal backslash. Text between single quotes
216.RB ` \' ... \' '
217is read
218entirely as-is, including all whitespace, newlines, backslashes,
219everything. To include a single quote in a piece of single-quoted text,
220use the sequence
221.RB ` \'\e\'\' ',
222as in the shell. (This drops out of single-quoting, inserts an escaped
223single quote, and resumes quoting.) Text between double quotes
224.BR """" ... """"
225is partially quoted: delimiters and whitespace are read as normal
226characters, but substitutions using the
227.RB ` $ '
228and
229.RB ` \` '
230characters are still made, and the backslash retains its behaviour of
231escaping the following character.
232.PP
233Two sorts of substitutions are available in values:
234.I "variable substitution"
235examines a variable and substitutes some text based on its value, and
236.I "command substitution"
237runs a command and substitutes its output.
238.PP
239The simplest variable substitution takes the form
240.RB ` $\c
241.IR name ':
242this is replaced by the value of the variable called
243.IR name ,
244or the empty string if there is no such variable defined. The name may
245be enclosed in braces should it be necessary to clearly disambiguate the
246end of the name.
247.PP
248More complex variable substitutions are permitted:
249.TP
250.BI ${ name \- text }
251Expands to the value of the variable called
252.I name
253if it's defined, or
254.I text
255if not.
256.TP
257.BI ${ name + text }
258Expands to
259.I text
260if there is a variable called
261.I name
262defined, or nothing.
263.TP
264.BI ${ name = text }
265If there is no variable called
266.I name
267then create one with the value
268.IR text ;
269then expands to the variable's value.
270.PP
271In each of the above, prefixing the operator character
272.RB ` \- ',
273.RB ` + '
274or
275.RB ` = '
276with a colon
277.RB (` : ')
278changes the variable existence test, such that it will believe that a
279variable whose value is the empty string is not defined. Each
280.I text
281part in the above forms is syntactically a
282.IR value ,
283and may itself contain quoting and substitutions. It may also contain
284unescaped whitespace.
285.PP
286There are two forms for command substitution: the backtick form, where a
287command is enclosed in backquotes
288.RB ` \` ... \` ';
289and the parenthesized form
290.RB ` $( ... ) '.
291The only difference between these two forms is syntactic: it's easy to
292make the parenthesized version nest, although that's not actually very
293useful. The text between the backquotes or parentheses is broken into
294words and executed as a command. It is not passed through the shell:
295the author suspects that this would be too confusing. The standard
296output of the command, with trailing newlines (but not internal or
297leading newlines) removed, is the result of the substitution.
be07bee0 298.
299.\"--------------------------------------------------------------------------
300.
f73dea54 301.SH "AUTHOR"
be07bee0 302.
e45f5509 303The \*(sw program, and this manual, are \*(mw productions, in association
304with the European Bioinformatics Institute. They were written by Mark
305Wooding <mdw@nsict.org>. Go and ask him if you have problems.
be07bee0 306.
307.\"----- That's all, folks --------------------------------------------------