GNU Rush |
|
Restricted User Shell |
Sergey Poznyakoff |
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.
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 begin with a letter and consist of letters, digits, underscores and dashes. They serve as keywords and variable names.
A sequence of decimal digits, optionally preceded by a minus or plus sign.
An unquoted string is any contiguous sequence of any characters, except newlines, whitespace and the following special characters: ‘\’, ‘"’, ‘!’, ‘=’, ‘<’, ‘>’, ‘(’, ‘)’, ‘{’, ‘}’, ‘[’, ‘]’, ‘$’, ‘%’, ‘&’, ‘|’, ‘~’, ‘#’.
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:
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) |
\\ | Single backslash character |
\" | Double-quote |
\% | Percent character |
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 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:
Reference | Meaning |
${var:-word} | Use Default Values |
${var:=word} | Assign Default Values |
${var:?word} | Display Error if Null or Unset |
${var:+word} | Use Alternate Value |
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.
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 |
‘in’ | Membership in set of strings |
‘group’ | Membership in UNIX group |
‘=’ | Assignment |
‘=~’ | Regular expression substitution |
See Matching Conditions, for a detailed discussion.
This document was generated on January 2, 2022 using makeinfo.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.