On Wed, Sep 3, 2014 at 9:09 PM, Chet Ramey <chet.ra...@case.edu> 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, https://github.com/lolilolicon/FFcast/blob/master/HACKING.markdown