fix: assign to functions hash to make %x work #460
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:0=${(%):-%x}
However to make it fully work under Zinit, it has to define its emulated autoload function with:
functions[func]="…"
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: