Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: crash with nameref and local argv
- X-seq: zsh-workers 54041
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: crash with nameref and local argv
- Date: Wed, 5 Nov 2025 22:47:24 +0100
- Archived-at: <https://zsh.org/workers/54041>
- In-reply-to: <CAH+w=7Ynqkk_VVbrxapRkKP10k47BqKXxga=ZbOyPWyNubmLvA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAHYJk3Qe7XuGv_B8nFUdHLD4C_kSgaJkS5acAFWTJ2Db_GWoUQ@mail.gmail.com> <CAHYJk3RW-a5_sG4sc4pN-X3=Q1AQ2rZbBsKidWXEBzJps8piZw@mail.gmail.com> <CAH+w=7YuE2GzH1F9r9Q6WmJxk1puj1M1qmSLsQ76pJ2r+49r4g@mail.gmail.com> <CAH+w=7YWh4nS__qzBEb3i9_OYfTkYfqLYSigEp+Obyp6_K+nDg@mail.gmail.com> <CAHYJk3Qy-Hikeo7TkXq9QAAy35MBDwA_iragpFekT9z5dN3ctg@mail.gmail.com> <CAH+w=7Ynqkk_VVbrxapRkKP10k47BqKXxga=ZbOyPWyNubmLvA@mail.gmail.com>
On Wed, Nov 5, 2025 at 9:26 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Tue, Nov 4, 2025 at 9:23 PM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> >
> > Would that break this code (which currently works)?
> > % () { local -h argv=hello; () { local argv=( $argv ); typeset -nu
> > foo=argv; echo $foo } } noot
> > hello
>
> Yes, it would ... but the test for whether "typeset -nu foo=argv" is
> valid becomes really ugly in that case, because it's no longer just
> syntactic ... it's necessary to instead find out if there actually
> exists a local variable "argv" (or "ARGC") at exactly one level less
> than the current scope.
>
> The semantics of something like the following is therefore pretty murky:
>
> () {
> local -h argv=hello;
> () {
> : There is an argv in this scope that is not the outer local
> () {
> typset -nu foo=argv # What does this mean?
> }
> }
> }
>
> Seems like a blanket ban on referencing $argv makes more sense, given
> that $@ and $* are also "illegal", even if it breaks your current
> example; I don't think it's possible to make the general case of
> peeking up the C stack succeed, so the alternative is to have it fail
> unpredictably at dereference time.
That makes sense, just wanted to make sure all bases were considered.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author