builtin-option
declare -n / local -n
Bash 4.3+ name reference. Assignment through the reference changes its visible target; use fixed trusted names, avoid collisions and cycles. The reference itself is not an array variable.
Formal Syntax & Structure
bash syntaxbash
declare -n ref=targetParameters & Attributes
| Name | Type | Description |
|---|---|---|
| ref | variable name | Name of the reference variable |
| target | trusted variable name | Target resolved in dynamic scope |
Return Value
exit status
Bash 4.3+ name reference. Assignment through the reference changes its visible target; use fixed trusted names, avoid collisions and cycles. The reference itself is not an array variable.
Working Example
Example Snippetbash
result=beforeupdate() { local -n bm_ref=result bm_ref=after}updateprintf '%s\n' "$result"