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