bug-bash
[Top][All Lists]
Advanced

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

Re: param expansion with single-character special vars in the environmen


From: Piotr Grzybowski
Subject: Re: param expansion with single-character special vars in the environment
Date: Thu, 28 Apr 2016 21:14:30 +0200

 ok, after some thinking, this one seems certain:

1. forbid adding nameref when the value is not a valid identifier:
 # declare -n reference=/
 should be forbidden, as well as later assignments to nameref with strings 
being illegal identifiers, as we discussed/patched.


 what remains (rest of the reports by Grisha and others can be brought to this):

2. creating a reference that "masks" the readonly variable:
  # bash -c 'declare -r T=a; echo $T; declare -n ref=a T; ref=bbbb; echo $T; 
declare -p T;'
  a
  bbbb
  declare -nr T="a"

 a. we can patch to expand always to the readonly variable value:
   # echo $T
   would not follow references but first resolve to value of T, as expected by 
most
   and introduce another way to dereference at expansion for those who did 
create the namref
   on purpose.

 b. we can forbid
   # declare -n T
   when T is a readonly variable

 c. we can forbid the assignment: 
   # ref=bbbb

 d. try to detect the "nameref loop"

2.b-d seem illogical to me, and against the decision behind introducing the 
namerefs.

cheers,
pg



On 28 Apr 2016, at 02:36, Grisha Levit wrote:

> 
> On Wed, Apr 27, 2016 at 6:47 PM, Piotr Grzybowski <address@hidden> wrote:
> +             if (v == 0 && onref || ( onref && !legal_identifier(value)))
> 
> Shouldn't this (and the other patch) check valid_array_reference as well to 
> support declare -n ref=a[x] ?




reply via email to

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