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 ref

Parameters & Attributes

NameTypeDescription
refvariable nameName 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'
Bash Reference