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