bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: declare [-+]n behavior on existing (chained) namerefs


From: Grisha Levit
Subject: Re: declare [-+]n behavior on existing (chained) namerefs
Date: Fri, 29 Apr 2016 12:50:06 -0400

I should note also that the behavior when inside a function matches exactly what the manual says. It’s the global namerefs that have this unexpected behavior of following the chain to the end and and modifying only the last nameref in the chain.

The only buggy behavior when inside of functions (ignoring scope issues) seems to be that `declare -n ref’ unsets the value of $ref if it previously pointed to a variable that is unset.

$ f() { unset var; declare -n ref=var; declare -n ref; declare -p ref; }; f
declare -n ref     # why did the value of ref disappear?

$ f() { local var; declare -n ref=var; declare -n ref; declare -p ref; }; f
declare -n ref="var"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]