bug-bash
[Top][All Lists]
Advanced

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

Re: Unable to dereference function-local nameref to global variable of s


From: Andreas Kusalananda Kähäri
Subject: Re: Unable to dereference function-local nameref to global variable of same name
Date: Fri, 12 Aug 2016 17:30:46 +0200
User-agent: Mutt/1.6.2 (2016-07-01)

On Fri, Aug 12, 2016 at 09:34:40AM -0400, Chet Ramey wrote:
> On 8/10/16 12:06 PM, Andreas Kusalananda Kähäri wrote:
> 
> > Bash Version: 4.3
> > Patch Level: 46
> > Release Status: release
> > 
> > Description:
> >     When declaring a variable in a function as a nameref, it can not
> >     be dereferenced if the variable it's a nameref to happen to have
> >     the same name as the nameref itself.  This imposes unnecessary
> >     restrictions on the caller.
> 
> There was extensive discussion about namerefs on bug-bash earlier this
> year.  I have a reasonable suggestion about how to change this behavior,
> and I will be looking at it after bash-4.4 is released.

Thanks Chet.

I'm mostly a ksh user, and the background to my report above is
that I was trying to make a tiny library of shell functions for
manipulating PATH-like shell variables available to bash users while
still maintaining functionality in both shells.  All functions were
using a local nameref called "var" and the issue came up when one
function tried to use one of the others.

My workaround is currently to slightly obfuscate the name of the local
nameref previously called "var" in each function so that their names
won't clash within the library and so that it's less likely that they
clash with global variables in the shell.

I'm looking forward to a future bash release!

Regards,

Attachment: signature.asc
Description: PGP signature


reply via email to

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