- = A hard assignment. The variable is assigned as soon as the statement is evaluated. If the assignment contains a reference to another variable then that reference will be included in the assignment rather that the value of the reference.
- ?= Defines a variable only if it is undefined at the time of parsing.
- ??= Assignment does not occur until the end of the parsing process.
- := Immediate variable expansion
- += Appending with spaces.
- =+ Prepending with spaces.
- .= Appending without spaces.
- =. Prepending without spaces.
Assignment Using Overrides
Variables can be appended or prepended using the override style syntax. In the example below B becomes equal to “bval additional data” and C becomes equal to “additional data cval”. Note that no additional spaces are include over what is in the original variable definitions.
B = "bval" B_append = " additional data" C = "cval" C_prepend = "additional data "
Removal of data can also be accomplished. In the following example FOO becomes equal to “ghi abcdef”. Note that surrounding spaces are also removed.
FOO = "abc def ghi abcdef abc def abc def" FOO_remove = "abc def"
Examples
In the following example the value of A is set to “aval”. The value of B is set to “pre${A}post”. In other words the value of B becomes dependent on the value of A at the times it is referenced. If the value of A changes between references to B the value of B will be different at those times.
A = "aval" B = "pre${A}post"
The following code includes some immediate variable assignment. The value of A becomes “test 123” as the values of A and B are unassigned at the time of As assignment.
T = "123"
A := "${B} ${A} test ${T}"
The following code uses a soft assignment. A is only assigned if the value is currently unassigned. The code therefore results in A being given the value of “one”
A ?= "one"
A ?= "two"
The following code uses weak assignment. A is not assigned until the end of the parsing process and is therefore given a value of “two”
A ??= "one"
A ??= "two"