GNU Rush – a restricted user shell (split by section):   Section:   Chapter:FastBack: Configuration File   Up: Configuration File   FastForward: Default Configuration   Contents: Table of ContentsIndex: Concept Index

4.1 Lexical Structure of the Configuration File

Configuration file consists of tokens separated by arbitrary amount of whitespace characters: horizontal spaces and tabs. Except when enclosed in double quotes or preceded by a dollar sign, the ‘#’ character introduces an inline comment: the character itself and any material that follows it up to the end of the physical line is ignored. Comments are treated as newlines.

The following classes of tokens are recognized.

Newlines

A newline character (ASCII 10) terminates a statement. If newline is immediately preceded by a backslash, both characters are removed and the following line is treated as a continuation of the current line. This allows for splitting exceedingly long statements over several physical lines.

Identifiers

Identifiers begin with a letter and consist of letters, digits, underscores and dashes. They serve as keywords and variable names.

Decimal numbers

A sequence of decimal digits, optionally preceded by a minus or plus sign.

Unquoted strings

An unquoted string is any contiguous sequence of any characters, except newlines, whitespace and the following special characters: ‘\’, ‘"’, ‘!’, ‘=’, ‘<’, ‘>’, ‘(’, ‘)’, ‘{’, ‘}’, ‘[’, ‘]’, ‘$’, ‘%’, ‘&’, ‘|’, ‘~’, ‘#’.

Quoted strings

A quoted string is a sequence of characters enclosed in double-quotes. Quoted strings are subject to backslash interpretation, backreference interpretation and variable expansion.

During backslash interpretation, the escape sequences are recognized and replaced as per table below:

SequenceReplaced with
\aAudible bell character (ASCII 7)
\bBackspace character (ASCII 8)
\fForm-feed character (ASCII 12)
\nNewline character (ASCII 10)
\rCarriage return character (ASCII 13)
\tHorizontal tabulation character (ASCII 9)
\vVertical tabulation character (ASCII 11)
\\Single backslash character
\"Double-quote
\%Percent character

Table 4.1: Backslash escapes

A backslash immediately followed by newline character is removed. A backslash followed by any other character except as listed above is retained along with the character.

During backreference interpretation, references to parenthesized groups in regular expression are replaced with the actual content of the corresponding group in the most recently matched string. A reference is ‘%{n}’ where n is a decimal number. If n is one digit, curly braces can be omitted: ‘%n’. If the ‘%’ character results from previous backslash interpretation, no backreference interpretation occurs.

Strings used in the left-hand side of a comparison expression are subject to variable expansion. This is discussed in detail in Variable expansion.

Variable references

Variable references consist of a ‘$’ sign, followed by the positional argument number or variable name, optionally enclosed in curly braces. Positional arguments greater than 9 must be enclosed in curly braces. The variable name must follow the rules for valid identifiers: it must begin with a letter and consist of letters, digits and underscores. Variable name in curly braces can be followed by ‘-’, ‘=’, ‘?’, or ‘+’, optionally preceded by ‘:’ as summarized in the table below:

ReferenceMeaning
${var:-word}Use Default Values
${var:=word}Assign Default Values
${var:?word}Display Error if Null or Unset
${var:+word}Use Alternate Value

Table 4.2: Variable reference

Where word stands for any valid token as described in this section. See Variable expansion, for a detailed discussion of these forms and their meaning.

Comparison and boolean operators

These are:

&&Boolean and
||Boolean or
!Boolean negation
==Equality (string or numeric)
!=Inequality (string or numeric)
<Less than
<=Less than or equal to
>Greater than
>=Greater than or equal to
~Regexp matching
!~Negated regexp matching
inMembership in set of strings
groupMembership in UNIX group
=Assignment
=~Regular expression substitution

Table 4.3: Operators

See Matching Conditions, for a detailed discussion.

GNU Rush – a restricted user shell (split by section):   Section:   Chapter:FastBack: Configuration File   Up: Configuration File   FastForward: Default Configuration   Contents: Table of ContentsIndex: Concept Index