Re: delcare -a on a nameref in a function modifies nameref instead of target

2018-08-09 Thread Chet Ramey
On 8/6/18 10:13 PM, Grisha Levit wrote: > A few more problematic test cases in this vein (tested against latest > devel snapshot 20180803). Thanks for the report. These are all the same issue, with the same fix. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer

Re: delcare -a on a nameref in a function modifies nameref instead of target

2018-08-06 Thread Grisha Levit
A few more problematic test cases in this vein (tested against latest devel snapshot 20180803). f() { local -n ref=var; local -A ref=([1]=); ref=([2]=); declare -p ref var; } unset ref var; f # declare -An ref=() # declare -A var=([1]="" ) declare -p ref # declare -a ref=([2]="") unset ref;

Re: delcare -a on a nameref in a function modifies nameref instead of target

2018-07-30 Thread Chet Ramey
On 7/29/18 4:04 PM, Grisha Levit wrote: > I think there's a related regression in the latest devel commit. Creating a > local variable with the same name as a higher-scoped nameref pointing to an > unset variable creates a local variable with the name of the target of the > nameref. I think

Re: delcare -a on a nameref in a function modifies nameref instead of target

2018-07-29 Thread Grisha Levit
I think there's a related regression in the latest devel commit. Creating a local variable with the same name as a higher-scoped nameref pointing to an unset variable creates a local variable with the name of the target of the nameref. Starting with: declare -n ref=var f() { local ref=Y;

Re: delcare -a on a nameref in a function modifies nameref instead of target

2018-07-26 Thread Chet Ramey
On 7/25/18 4:27 PM, Grisha Levit wrote: > In the latest devel this issue is fixed for the case that the local nameref > points to a non-existent variable but there is still a bug if the variable > pointed to by a local nameref already exists. Thanks for the report. The original fix was too

Re: delcare -a on a nameref in a function modifies nameref instead of target

2018-07-25 Thread Grisha Levit
In the latest devel this issue is fixed for the case that the local nameref points to a non-existent variable but there is still a bug if the variable pointed to by a local nameref already exists. In such a case, `declare' commands after the initial `declare -n' end up modifying the value and/or

Re: delcare -a on a nameref in a function modifies nameref instead of target

2018-07-19 Thread Grisha Levit
On Wed, Jul 18, 2018 at 8:23 AM Greg Wooledge wrote: > FYI that one is already fixed in 5.0-alpha: > > wooledg:~$ declare -n ref=var; declare -a ref=(X); declare -p ref var > declare -n ref="var" > declare -a var=([0]="X") > wooledg:~$ f() { declare -n ref=var; declare ref=(X); declare -p ref

Re: delcare -a on a nameref in a function modifies nameref instead of target

2018-07-18 Thread Greg Wooledge
On Tue, Jul 17, 2018 at 05:47:20PM -0400, Grisha Levit wrote: > At global scope this works as expected: > > $ declare -n ref=var; declare -a ref=(X); declare -p ref var > declare -n ref="var" > declare -a var=([0]="X") > > But in a function, we end up with the nameref variable having both the >

delcare -a on a nameref in a function modifies nameref instead of target

2018-07-17 Thread Grisha Levit
At global scope this works as expected: $ declare -n ref=var; declare -a ref=(X); declare -p ref var declare -n ref="var" declare -a var=([0]="X") But in a function, we end up with the nameref variable having both the `a' and `n' attributes and nothing in the target: $ f() { declare -n ref=var;