Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Named reference typos & misc.



On Wed, Feb 15, 2023 at 2:37 AM Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:
>
> > On 15/02/2023 10:12 Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> >
> > On 14/02/2023 20:00 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> > > Unrelated:
> > > > I kept the loop in the function to avoid a (correct) additional warning
> > > > message setting the global variable ref in the loop.  I don't know if
> > > > setting ref in a for loop should actually elide that message, which
> > > > is a completely separate issue.
> > >
> > > You mean an assignment within the loop, while "ref" already points out
> > > of it?  I would think that'd be expected to trigger warn_create_global
> > > instead,
> >
> > Yes, and it usually does with normal references, so I guess there's a
> > different case here with namerefs.
>
> "... with normal VARIABLES", sorry, that's confusing the issue.

% () {
function> typeset -n ref
function> setopt warncreateglobal
function> for ref in a b c; ref=$((++i))
function> }
(anon):3: numeric parameter i created globally in function (anon)
(anon):3: scalar parameter a created globally in function (anon)
(anon):3: scalar parameter b created globally in function (anon)
(anon):3: scalar parameter c created globally in function (anon)
% typeset -p a b c
typeset a=1
typeset b=2
typeset c=3

I think this is working as would be expected.




Messages sorted by: Reverse Date, Date, Thread, Author