2.7 Variable name references

The preprocessor implements facilities to declare variables with unique names and use them as target for variables with the NAMEREF attribute.

The basic usage pattern is to declare a variable in a caller function with the preprocessor directive mbfl_declare_varref() and to access such a variable from a callee function using the preprocessor directive mbfl_mandatory_nameref_parameter() as follows:

function caller () {
    mbfl_declare_varref(VAR)

    callee mbfl_datavar(VAR)
    echo $VAR
}

function callee () {
    mbfl_mandatory_nameref_parameter(VAR, 1, variable reference)

    VAR=123
}

mutating the variable ‘VAR’ in callee() will mutate the variable VAR in caller(). For details on declaring the variable Full NAMEREF declarations. For details on accessing the variable Preprocessor parameters.


This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.