refactor(ziextract): declare →zinit-extract once from a body variable - #3
Draft
vladdoster with Copilot wants to merge 5 commits into
Draft
refactor(ziextract): declare →zinit-extract once from a body variable#3vladdoster with Copilot wants to merge 5 commits into
vladdoster with Copilot wants to merge 5 commits into
Conversation
Copilot
AI
changed the title
[WIP] Refactor ziextract case statement to reduce duplicate declaration
refactor(ziextract): declare →zinit-extract once from a body variable
Jul 24, 2026
There was a problem hiding this comment.
Pull request overview
Refactors ziextract to avoid repeating the →zinit-extract() function declaration across each archive-type case branch by storing per-branch extraction logic in a body variable and declaring the function once after the case.
Changes:
- Introduces a local
bodyvariable and updates eachcasebranch to assign the extractor function body instead of redefining→zinit-extract(). - Declares
→zinit-extract()once afteresac(gated by[[ -n $body ]]) and runs extraction via.zinit-extract-wrapper.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1730
to
1732
| if [[ -n $body ]] { | ||
| builtin eval "→zinit-extract() { $body }" | ||
| .zinit-extract-wrapper "$file" →zinit-extract || { |
Author
There was a problem hiding this comment.
Added a newline terminator before the closing } when building the eval string in 378a439.
Comment on lines
1709
to
1711
| command cp -Rf ${attached_vol:-${TMPDIR:-/tmp}/acb321GEF}/*(D) . | ||
| retval=$? | ||
| command hdiutil detach $attached_vol |
Author
There was a problem hiding this comment.
Quoted $attached_vol in both cp (keeping the glob unquoted so it still expands) and hdiutil detach in 378a439.
- zinit-install.zsh: guard Makefile glob in ∞zinit-make-base-hook with (N.) qualifier so it doesn't fail with 'no matches found' when configure didn't produce a Makefile - tests/plugins.zunit: use 'build' ice for tmux on all platforms (removes darwin-specific configure'--disable-utf8proc' that fails with current tmux autogen/configure)"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ziextract's extensioncasestatement repeated the→zinit-extract() { … }declaration in all 15 branches. Each branch now sets only the function body, and the function is declared in a single place.Case statement
bodyinstead of declaring a function. No expansion happens at assignment time;$file,ZINIT[tmp], and grep patterns resolve at call time as before.Single declaration point
→zinit-extractis created once afteresac.[[ -n $body ]]replaces the$(typeset -f + →zinit-extract)subshell check that gated the extraction/warning=1paths.Notes for reviewers
builtin evalis used rather thanfunctions[→zinit-extract]=$body: zsh 5.9 mangles the multi-byte→in identifiers when parsing a body assigned through thefunctionsarray, breaking the→zinit-checkcalls. The evaluated string is a static literal..gz/.bz2/.xzbranches keep their pre-existing file-rename logic outside the body assignment.→zinit-extractdeclaration in ziextract case statement #1