Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Andrej Podzimek Newsgroups: gnu.bash.bug Subject: Re: Variable references (declare -n, "nameref") are limited to a depth of 8. Date: Sun, 26 Apr 2020 05:46:15 +0200 (GMT+02:00) Lines: 32 Approved: bug-bash@gnu.org Message-ID: References: <09fac3bd-2d96-c0ee-ac03-f729507af74a@case.edu> <1b9cc5d.a1fea93e.171b497bdae@podzimek.org> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: usenet.stanford.edu 1587872792 5781 209.51.188.17 (26 Apr 2020 03:46:32 GMT) X-Complaints-To: action@cs.stanford.edu Cc: chet.ramey@case.edu To: chet.ramey@case.edu, bug-bash@gnu.org Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=podzimek.org; s=charon; t=1587872780; bh=INsCAGgfDsQkdxP9tgMr5Uh3Y71ONWh2c+0cQBZgbec=; l=1251; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=kvTTDn2CzZHsi1B2bMSCLOFLAyV9iTUZkLLvejViIi0ltHtRcFOkSMUu9E9eZD0iY k6VVYH5d/coaNuJxGz8x2s7Zcz+wGH+CfLSIfwTvCejknNE8vQIudFf19UbUZ8Pgvd Z3WdRHUkFlsdmhTJiOxy24HtNpXZyTzYV96gk4e5TnfY5e5MYo+dZmeu4ehucnzTsh 86gvwFmHZx9RN9q1rE7uTU/8LXvoNZ6MQs974ovy93umGDZNiCqiUtzx55uxGw2hKz jqH7rwmqbCpotBSmfj7TXEnW6kJV45k0RaOBw+4IxRP7khIFVcmAeKvvmbcJJaqgoB ELvzHni3UQfyw== Authentication-Results: podzimek.org; auth=pass (details omitted) In-Reply-To: <09fac3bd-2d96-c0ee-ac03-f729507af74a@case.edu> X-Mailer: R2Mail2 Received-SPF: pass client-ip=2a02:168:5cd0::; envelope-from=andrej@podzimek.org; helo=charon.podzimek.org X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2a02:168:5cd0:: X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <1b9cc5d.a1fea93e.171b497bdae@podzimek.org> X-Mailman-Original-References: <09fac3bd-2d96-c0ee-ac03-f729507af74a@case.edu> Xref: csiph.com gnu.bash.bug:16244 >> Description: >>=20 >> While looking for a way to share a "cache" array with a recursive func= tion >> call stack (using local -n (nameref)), I hit a well-known problem with >> "circular name reference" (which has been around for a long time).=20 >=20 > Yes, that's how it does loop detection. There are, however, no loops involved in my $a =E2=80=A6 $k example; it is = merely a chain of declare -n references starting from a regular variable $a= . The chain breaks unexpectedly and silently after 8 links ($j and $k appea= r to be empty). Better options, IMHO, would include: (a) An unlimited number of declare -n resolution steps (as long as there ar= e no cycles, i.e., no variable name(*) is encountered twice). This may have= performance consequences when abused, but it would be better than unexpect= ed empty values after >8 steps. (b) An error message when trying to dereference $j or $k (links No. 9 and 1= 0 in the chain example), saying e.g. =E2=80=9Cmaximum nameref depth (8) exc= eeded=E2=80=9D. This would at least make the problem obvious and easy to de= bug. (*) More precisely, this would be [function context, variable name] pairs i= n case of local variables referenced by declare -n. Andrej