Previous: Pragmatic Comments, Up: Configuration File Syntax [Contents][Index]
A simple statement consists of a keyword and a value separated by any amount of whitespace. It is terminated with a semicolon (‘;’), unless the value is a here-document (see below), in which case semicolon is optional.
Examples of simple statements:
timing yes; access-log-file /var/log/access_log;
A keyword begins with a letter and may contain letters, decimal digits, underscores (‘_’) and dashes (‘-’). Examples of keywords are: ‘group’, ‘identity-check’.
A value can be one of the following:
A number is a sequence of decimal digits.
A boolean value is one of the following: ‘yes’, ‘true’, ‘t’ or ‘1’, meaning true, and ‘no’, ‘false’, ‘nil’, ‘0’ meaning false.
An unquoted string may contain letters, digits, and any of the following characters: ‘_’, ‘-’, ‘.’, ‘/’, ‘@’, ‘*’, ‘:’.
A quoted string is any sequence of characters enclosed in double-quotes (‘"’). A backslash appearing within a quoted string introduces an escape sequence, which is replaced with a single character according to the following rules:
Sequence | Replaced with |
\a | Audible bell character (ASCII 7) |
\b | Backspace character (ASCII 8) |
\f | Form-feed character (ASCII 12) |
\n | Newline character (ASCII 10) |
\r | Carriage return character (ASCII 13) |
\t | Horizontal tabulation character (ASCII 9) |
\v | Vertical tabulation character (ASCII 11) |
\\ | A single backslash (‘\’) |
\" | A double-quote. |
In addition, the sequence ‘\newline’ is removed from the string. This allows you to split long strings over several physical lines, e.g.:
"a long string may be\ split over several lines"
If the character following a backslash is not one of those specified above, the backslash is ignored and a warning is issued.
Two or more adjacent quoted strings are concatenated, which gives another way to split long strings over several lines to improve readability. For instance, the following fragment produces the same result as the example above:
"a long string may be" " split over several lines"
A here-document is a special construct that allows the user to introduce strings of text containing embedded newlines.
The <<word
construct instructs the parser to read all
the following lines up to the line containing only word, with
possible trailing blanks. Any lines thus read are concatenated
together into a single string. For example:
<<EOT A multiline string EOT
The body of a here-document is interpreted the same way as a double-quoted string, unless word is preceded by a backslash (e.g. ‘<<\EOT’) or enclosed in double-quotes, in which case the text is read as is, without interpretation of escape sequences.
If word is prefixed with -
(a dash), then all leading
tab characters are stripped from input lines and the line containing
word. Furthermore, if -
is followed by a single space,
all leading whitespace is stripped from them. This allows for indenting
here-documents in a natural fashion. For example:
<<- TEXT All leading whitespace will be ignored when reading these lines. TEXT
It is important that the terminating delimiter be the only token on its line. The only exception to this rule is allowed if a here-document appears as the last element of a statement. In this case a semicolon can be placed on the same line with its terminating delimiter, as in:
help-text <<-EOT A sample help text. EOT;
A list is a comma-separated sequence of values. Lists are delimited by parentheses. The following example shows a statement whose value is a list of strings:
capability (mime,auth);
In any case where a list is appropriate, a single value is allowed without being a member of a list: it is equivalent to a list whose only member is that value. This means that, e.g. ‘capability mime;’ is equivalent to ‘capability (mime);’.
A block statement introduces a logical group of another statements. It consists of a keyword, followed by an optional value, and a sequence of statements enclosed in curly braces, as shown in the example below:
load-module outline { command "outline"; }
The closing curly brace may be followed by a semicolon, although this is not required.
Previous: Pragmatic Comments, Up: Configuration File Syntax [Contents][Index]