Re: Hiding specials, and namerefs
Philippe Altherr <[email protected]> Fri, 24 Jul 2026 04:12:03 +0200
| Newsgroups | gmane.comp.shells.zsh.devel |
|---|---|
| Message-ID | <CAGdYchuSvT8isj+cVMGFT83+O_dH8oN9Bq2tJEhbNSFoX5AMdw@mail.gmail.com> |
--000000000000b59698065751e624 Content-Type: text/plain; charset="UTF-8" > > While testing this I discovered that the same (silent no-op) behavior > applies to "typeset -gn" for specials, and for autoloads we get e.g. > this: > % typeset -gn SRANDOM > zsh: invalid variable name: zsh/random > I'll see if I can track that down. I have code that fixes this -> changes the error to "SRANDOM: can't change type of autoloaded parameter". I was reviewing the code of typeset_single in order to understand how special parameters get localized. I still haven't figured this out but I noticed that this condition <https://github.com/zsh-users/zsh/blob/2564174dd6f9289b4e4da2a8122b0f8edd8a62b4/Src/builtin.c#L2115> is most likely missing a PM_NAMEREF. After much more digging I finally ended up with changes that also fix the issue above. More work is needed before I can send patch(es) but what is already clear is that I need the same ability to tell assignsparam and assignaparam to not dereference the assigned parameter as in workers/55026 <https://zsh.org/workers/55026>. It would be great if you could commit that one, or at least the changes in zsh.h and params.c. Philippe --000000000000b59698065751e624 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><blockquote class=3D"gmail_quote" style= =3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding= -left:1ex">While testing this I discovered that the same (silent no-op) beh= avior<br>applies to "typeset -gn" for specials, and for autoloads= we get e.g.<br>this:</blockquote><blockquote class=3D"gmail_quote" style= =3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding= -left:1ex"><br>% typeset -gn SRANDOM<br>zsh: invalid variable name: zsh/ran= dom</blockquote><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0= px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>I'= ;ll see if I can track that down.</blockquote><div><span style=3D"backgroun= d-color:transparent"><br></span></div><div><span style=3D"background-color:= transparent">I have code that fixes this=C2=A0 -> changes the error to &= quot;</span><span style=3D"background-color:transparent">SRANDOM: can't= change type of autoloaded parameter".</span></div><div><span style=3D= "background-color:transparent"><br></span></div><div><span style=3D"backgro= und-color:transparent">I was reviewing the code of typeset_single in order = to understand how special parameters get localized. I still haven't fig= ured this out but I noticed that <a href=3D"https://github.com/zsh-users/zs= h/blob/2564174dd6f9289b4e4da2a8122b0f8edd8a62b4/Src/builtin.c#L2115">this c= ondition</a>=C2=A0is most likely missing a PM_NAMEREF. After much more digg= ing I finally ended up with changes that also fix the issue above. More wor= k is needed before I can send patch(es) but what is already clear is that I= need the same ability=C2=A0to tell assignsparam and=C2=A0</span><span styl= e=3D"background-color:transparent">assignaparam=C2=A0to not dereference the= assigned parameter as in=C2=A0</span><a href=3D"https://zsh.org/workers/55= 026" style=3D"background-color:transparent">workers/55026</a>. It would be = great if you could commit that one, or at least the changes in zsh.h and pa= rams.c.</div><div><br></div><div>Philippe</div><div><br></div></div></div> --000000000000b59698065751e624--