[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Passing variables by reference conflicts with local
From: |
Chet Ramey |
Subject: |
Re: Passing variables by reference conflicts with local |
Date: |
Fri, 30 Apr 2010 08:16:42 -0400 |
> In an attempt to improve the bash-completion package we're trying to
> improve the bash completion library functions by passing variables by
> reference. Passing variables by reference however, has a caveat in that
> local variables override the passing by reference, e.g.:
This isn't a problem specific to bash; it's a library interface design
issue. The usual solution is to pick a unique prefix for exported public
library functions (e.g., "rl_") and a different one for private library
variables and interfaces that's unlikely to conflict with anything a user
might use (e.g., "_rl_").
> Thoughts? Ideas? Is there a bash-builtin to detect conflicts? If not,
> wouldn't it be an idea to add such a builtin?
There's no reason to add a builtin to detect these conflicts. It's often
the case that overriding the global version of a variable is the desired
effect.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/