Next: , Previous: , Up: preprocessor nameref   [Contents][Index]


2.7.3 Partial NAMEREF declarations

Preprocessor Macro: mbfl_local_nameref (NAME, DATA_VARNAME_EXPR)

It expands into:

local mbfl_a_variable_NAME=DATA_VARNAME_EXPR
local -n NAME=$mbfl_a_variable_NAME

Declare a proxy variable NAME aliasing the data variable whose value is the result of evaluating DATA_VARNAME_EXPR.

We can use this macro as follows:

function main () {
    local VARNAME
    worker VARNAME
    mbfl_local_nameref(VAR, $VARNAME)
    ...
}

function worker () {
    mbfl_mandatory_nameref_parameter(RV, 1)
    mbfl_global_varref(VAR, 123)
    RV=mbfl_datavar(VAR)
}

main

Next: , Previous: , Up: preprocessor nameref   [Contents][Index]

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