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

Re: What's the opposite of ZSH_ARGZERO?



On Wed, Mar 6, 2024 at 1:57 PM Felipe Contreras
<felipe.contreras@xxxxxxxxx> wrote:
>
> But what if someone wants to do the opposite? Use the zsh $0 even if
> POSIX_ARGZERO is on?

Of course the zsh $0 depends on the setting of FUNCTION_ARGZERO, but I
know what you mean.

> So far I've found that ${(%):-%N} is the best option, but I wonder if
> there is a better one.

$funcstack[1] would be the other option, unless for some odd reason
the zsh/parameter module is not available.

An advantage of $funcstack is that you can use
${${(@)funcstack:#'(anon)'}[1]} to get the name of the nearest
non-anonymous function.




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