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