fix: prevent "permission denied" errors from empty hook handlers #729
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.
Fixes #728
Summary
This PR fixes the "permission denied: " errors that occur when zinit tries to execute empty hook handlers from annexes.
Problem
When loading certain annexes, zinit attempts to execute hook handlers that may be empty or undefined. This results in the shell trying to execute an empty command, which produces "permission denied: " errors:
Solution
Added checks to ensure hook handlers are non-empty before attempting to execute them:
.zinit-load()
function: Check if${___arr[5]}
is non-empty before execution.zinit-load-snippet()
function: Check if${arr[5]}
is non-empty before executionChanges
zinit.zsh
:.zinit-load()
at line 1650.zinit-load-snippet()
at line 1446tests/empty-hook-handler.zunit
to ensure:Testing
Backwards Compatibility
This change is fully backwards compatible. It only adds a safety check and doesn't change any existing behavior for valid hook handlers.
Related Issues
This issue has been reported by multiple users experiencing "permission denied" errors when using zinit annexes.