Closed psprint closed 1 year ago
I can't quite tell what this fixes. Could you share a screenshot?
I thought it would fix the following issue at a cursory glance, but I guessed wrong.
Here is the screenshot:
@psprint,
I'm still unclear on what this fixes. Does it improve a certain ice, command, or just zsh programming in general?
It allows to use better $0 retriever code than the currently recommended in plugin standard. So maybe yes it improves zsh programming in general. I'll be writing a patch to the standard if the zinit problem will be fixed.
Could the PR be merged? It`s a very local, isolated change, basically a bug fix. To provide more info on what it does:
%x
is a prompt expansion, which is used in a ${(%)…}
expansion that enables the expansion outside the prompt,%x
would expand only in $PROMPT/$PS/
etc. vars when printing prompt, while with (%)
it expands in the place of use,%x
is a useful expansion, it returns path to the currently executed script or function,$0
to the plg.plugin.zsh
file, or even to any executed function,autoload
of Zinit is currently broken when first used the autoloaded func, when the function is loaded before first execution,%x
return the path to the function correctly, even at first call.Is everything clear? I'm holding back because %x
isn't fixed in Zinit, before updating the plugin standard, it's 0=…
recommendation there.
Thanks for merging. Could some other my PRs be merged? Like those mentioned in #448 ?
The useful %x prompt expansion can be used to get path to the executed script:
0=${(%):-%x}
Description
It is always the correct, expected value, even for autoloaded functions. However, it currently doesn't work with Zinit special fpath-pollution free autoload. This patch fixes this.
Motivation and Context
It is comfortable to get correct
$0
even for autoloaded functions with:However to make it fully work under Zinit, it has to define its emulated autoload function with:
instead of:
because the eval method returns wrong path at first function execution (returns path to
name.plugin.zsh
instead). That's the change of this PR.How Has This Been Tested?
The change has to work, it's very isolated.
Types of changes
Checklist: