Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH v6] regexp-replace and ^, word boundary or look-behind operators (and more).
- X-seq: zsh-workers 54736
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Mikael Magnusson <mikachu@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH v6] regexp-replace and ^, word boundary or look-behind operators (and more).
- Date: Wed, 10 Jun 2026 05:13:41 +0200
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PsVHXsgPQHzu/iuPYYJuPAxVTpOdRJydtLBvNTwafqQ=; fh=yg4TJC2UkjZ3gAKcAZvQv8gFDvpKdhedS9RSfPxOeZk=; b=Ia7jQKYA1Ra3l8kr77unq491MzN3jOxyglcaVgxdOlKTjq+FHOjMdyf7bOZtH8vR8n jgY02yppN5mXyrg7cr0P4AL+PI0momwFZ2X/T1tEoX+l7BosW4cjx4GGV55ZHRfW7eVC MN0o2ppa2Ka8ClfKFtTASqf9wmNrS36Cwl34xCAHAVra1nqBQXb6LsKPfWfngiiUw1lm +Elz49BGay2aWw/IX/vCdH+i0UDs7PkFOCh9pf2xN+AVKFZ8dyKg1NVuzhbKwbje/NCx dHENU6zProd5iXIXQlkexuXE7T7vljqXJ3gx5DPhicBEwsYyyfqKrBt6wa+p6uUi5T9D otfg==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1781061236; cv=none; d=google.com; s=arc-20240605; b=jLaCrKzT6MbemGTPAEw7kI++CDiw8raNqIQFgxVw8KKz9NbWaWZIi30THHuiMSfuf9 UDHRrdHZYEunrfwnYOm1nMRsKbnXqioPr28486XshtrIRYezEEcS2kkb4hzCWwmDjXmd nrnB67vuG5P0UadkDrFEZaiPJHjMq4RfvYFlGv/CJ6n8hYQJQg4qUp2SNWWJ8NtdFm0f Q1aMPF7ActDU3Bj3+fTcCdPFZr3E7Irbrb7m0wJfI/5w2Wl3f1dT/xdeHhK6TeRysTfY 0Y48/Zk3zPcD3aLY0HwM41ScR7QxVfyIF+aevao+W/pKqeSuaKDMYq4mXGDV8HQQZhYS rCow==
- Archived-at: <https://zsh.org/workers/54736>
- In-reply-to: <aiVsxly6arks7UDE@chazelas.org>
- List-id: <zsh-workers.zsh.org>
- References: <20200101140343.qwfx2xaojumuds3d@chaz.gmail.com> <20210430061117.buyhdhky5crqjrf2@chazelas.org> <CAH+w=7bHxSbFr60ZU0+oZ6+qEejhfBYTzvL7=aXadY5XzWtSzw@mail.gmail.com> <20210505114521.bemoiekpophssbug@chazelas.org> <20240308153050.u63fqtcjyr2yewye@chazelas.org> <20240309130310.5zovit5jk6l4rnak@chazelas.org> <20240310195201.c53tzhgcyk5qgi27@chazelas.org> <CAHYJk3QBHeR9TTGtpRu4SapMAWo9OC-YQ71cO8aSDcuJ8QEp_Q@mail.gmail.com> <aiUvWWVf9MYQPa4m@chazelas.org> <CAHYJk3QEiJ0_x20dK4TOeztb5xVP3sx5=LB1upW54nmwX5f5AQ@mail.gmail.com> <aiVsxly6arks7UDE@chazelas.org>
On Sun, Jun 7, 2026 at 3:16 PM Stephane Chazelas <stephane@xxxxxxxxxxxx> wrote:
>
> 2026-06-07 12:36:53 +0200, Mikael Magnusson:
> [...]
> > setopt functionargzero does not take effect when we have already entered the
> > function, so use $funcstack[1] instead.
> [...]
>
> Thanks. I have to admit I'm a bit baffled as to how I ended up
> adding that (and that I would have thought about the case where
> functionargzero is unset in the first place).
>
> Probably by testing in other emulation modes.
>
> If $0 == functionname is not restored by emulate -L zsh, that
> would suggest we'd need to replace $0 with $funcstack[1] in all
> functions we expect to work whatever the user's set of options.
>
> I see $funcstack doesn't work when zsh is *started* in sh/ksh/csh
> emulation, but I wouldn't expect those instances to use
> autoloaded functions anyway.
Hmm, right, you'd have to do zmodload -F zsh/parameter p:funcstack
(this does take effect immediately, because the variable it reads is
maintained always by exec.c). Now that I've looked around in the code,
I see that we do indeed use $0 in a lot of places already. Maybe it's
better to just leave this as $0 too and leave that particular problem
to another cleanup. (It's weird how difficult it is to just
consistently get the name of the currently executing function.)
Maybe a reasonable compromise is just ${funcstack[1]:-$0} or so (but
of course, functionargzero is off in ksh emulation so that'll still
say ksh.) The absolutely simplest solution is to just replace all
instances of $0 with the name of the file :). Argh, if you're in ksh
emulation it's funcstack[0]. You just can't win.
TL;DR I'll just leave it as $0 but remove the setopt.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author