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: Thu, 28 Apr 2016 21:49:40 -0400

There is also an issue when doing something like `declare -n r=a' in a function if the same has been done in a higher scope.  Instead of creating a new variable r in the function's scope, it modifies the local `a' to be a self-referencing nameref..

$ declare -nt r=a; f() { declare a; declare -n r=a; declare -p a r; }; f
declare -n a="a"    # ??
declare -nt r="a"   # note the -t.  this is the outer $r, a new one was not created

In a slightly different version, with `declare -n r; r=a', the function exits with code 1 after the `r=a' statement:

$ declare -nt r=a; f() { declare a; declare -n r; r=a; declare -p a r; }; f; echo $?
1

reply via email to

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