builtin-option
unset -n
Remove the name reference itself instead of its target. Ordinary unset through a nameref may remove the referenced variable.
Formal Syntax & Structure
bash syntaxbash
unset -n refParameters & Attributes
| Name | Type | Description |
|---|---|---|
| ref | variable name | Name reference to remove |
Return Value
exit status
Remove the name reference itself instead of its target. Ordinary unset through a nameref may remove the referenced variable.
Working Example
Example Snippetbash
target=keepdeclare -n ref=targetunset -n refprintf 'target=%s\n' "$target"[[ -v ref ]] || printf 'reference=gone\n'