#### 3.2.2 Configuration Variables ¶

Certain configuration statements allow for the use of variable references in their values. A variable reference has the form ‘`$variable`’ or ‘`${variable}`’, where variable is the variable name. It is expanded to the actual value of variable when Mailutils consults the configuration statement in question.

The two forms are entirely equivalent. The form with curly braces is normally used if the variable name is immediately followed by an alphanumeric symbol, which will otherwise be considered part of it. This form also allows for specifying the action to take if the variable is undefined or expands to an empty value.

During variable expansion, the forms below cause Mailutils to test for a variable that is unset or null. Omitting the colon results in a test only for a variable that is unset.

${variable:-word}

  Use Default Values. If variable is unset or null, the expansion of word is substituted. Otherwise, the value of variable is substituted.

${variable:=word}

  Assign Default Values. If variable is unset or null, the expansion of word is assigned to variable. The value of variable is then substituted.

${variable:?word}

  Display Error if Null or Unset. If variable is null or unset, the expansion of word (or a message to that effect if word is not present) is output to the current logging channel. Otherwise, the value of variable is substituted.

${variable:+word}

  Use Alternate Value. If variable is null or unset, nothing is substituted, otherwise the expansion of word is substituted.

When a value is subject to variable expansion, it is also subject to command expansion. Commands are invoked in string values using the following format:

    $(cmd arg)

where cmd is the command name, and args is a list of arguments separated by whitespace. Arguments can in turn contain variable and command references.

The following commands are defined:

Command: localpart string ¶

  Treats string as an email address and returns the part preceding the ‘`@`’ sign. If there is no ‘`@`’ sign, returns string.

Command: domainpart string ¶

  Treats string as an email address and returns the part following the ‘`@`’ sign. If there is no ‘`@`’ sign, returns empty string.

Command: shell cmd args ¶

  Runs the shell command cmd with the given arguments. Returns the standard output from the command. The command is invoked using `/bin/sh -c` and can contain any valid shell constructs.

The subsections below define variable names that are valid for use in each configuration statement.