[Top][All Lists]

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

Re: nameref bug?

From: lolilolicon
Subject: Re: nameref bug?
Date: Thu, 4 Sep 2014 01:14:44 +0800

On Wed, Sep 3, 2014 at 9:09 PM, Chet Ramey <address@hidden> wrote:
>> There isn't much written on namerefs for two reasons:
>> 1) They're quite new.
>> 2) They're pretty useless. :(
> It depends on what your expectations are.  Namerefs are essentially variable
> name aliases.  For their stated purpose -- passing variable names to shell
> functions and allowing those functions to modify the named variable -- they
> are ok.

Yes, they're convenient, and make the code look somewhat more
readable, compared to equivalent `eval` or `printf -v` statements.
Functionally, they're all the same.
And they all suffer from the same issue. No matter which of those
three is used, one has to be very careful not to create name
collisions which can result in non-obvious bugs, sometimes deep in the
function call stack. One will have to invent his own variable naming
conventions to avoid such bugs; for instance, I have written a
reminder for my own script,

reply via email to

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