Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16831
| From | Greg Wooledge <wooledg@eeg.ccf.org> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: Incorrect / Inconsistent behavior with nameref assignments in functions |
| Date | 2020-08-28 12:14 -0400 |
| Message-ID | <mailman.1619.1598631287.2469.bug-bash@gnu.org> (permalink) |
| References | <a20e4692-69b3-9836-4861-3e822e407ef7@binarus.de> <20200828152846.GI931@eeg.ccf.org> <CAH7i3Lpq3dWx55mGcuu4TK0gQaLCFBQwcoaeWR_-tunwxK6ijQ@mail.gmail.com> <20200828161442.GJ931@eeg.ccf.org> |
On Fri, Aug 28, 2020 at 06:37:00PM +0300, Oğuz wrote:
> 28 Ağustos 2020 Cuma tarihinde Greg Wooledge <wooledg@eeg.ccf.org> yazdı:
> > func1() {
> > declare -n _func1_ref="$1"
> > local _func1_i
> > ...
> > }
> >
> This doesn't make the slightest sense. What is the point of having local
> variables then?
You need to distinguish between two types of functions: ones which
use namerefs, and ones which do not.
If a function doesn't use name references, then you may safely use
local variables with any names you like. Nothing has to change.
If a function is going to use a name reference, then you need to
bullet-proof it from head to toe. All local variables have to be
mangled to minimize the chance of collisions. It's an entirely
different problem.
Back to gnu.bash.bug | Previous | Next | Find similar
Re: Incorrect / Inconsistent behavior with nameref assignments in functions Greg Wooledge <wooledg@eeg.ccf.org> - 2020-08-28 12:14 -0400
csiph-web