nameref

A bash 4.3 variable declared with declare -n or local -n that acts as another name for a variable named by its value.

In more detail

Assigning to the nameref assigns to the variable it refers to, so a function can write its result into a variable the caller names, without eval. ShellCheck cannot follow the link and may report SC2034 for it.

Example

read_config() { local -n target="$1"; target="ledger.example.com"; }

Related terms

Taught in

References