fn () { declare -n var=foo; var=bar } unset foo fn echo ${foo:-unset}