Path: csiph.com!feeder.erje.net!1.eu.feeder.erje.net!fu-berlin.de!usenet.stanford.edu!not-for-mail From: Greg Wooledge Newsgroups: gnu.bash.bug Subject: Re: delcare -a on a nameref in a function modifies nameref instead of target Date: Wed, 18 Jul 2018 08:23:03 -0400 Lines: 25 Approved: bug-bash@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: usenet.stanford.edu 1531916620 17080 208.118.235.17 (18 Jul 2018 12:23:40 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash To: Grisha Levit Envelope-to: bug-bash@gnu.org Mail-Followup-To: Grisha Levit , bug-bash Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 139.137.100.1 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14357 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 > `a' and `n' attributes and nothing in the target: > > $ f() { declare -n ref=var; declare ref=(X); declare -p ref var; }; f > declare -an ref=([0]="X") > -bash: declare: var: not found 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 var; }; f declare -an ref=([0]="X") declare -a var=([0]="X") Or at least partly fixed. *shrug*