fix: stop modifying shell rc files in postinstall#801
Closed
Conversation
Replace the fragile .zshrc/.bashrc modification logic with a safer approach: only write completion files and print setup instructions. The previous approach tried to parse and splice into rc files, which broke multi-line shell commands (e.g. zinit blocks with backslash continuations matching /compinit/). Instead of attempting to fix the parser, remove rc modification entirely — this matches the approach used by rustup, homebrew, and other CLI tools. Closes #788
Owner
Author
|
Pushed the changes to PR #796 fork branch instead, as requested. |
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.
Summary
.zshrc/.bashrcmodification logic frompostinstall.js~/.zsh/completions/_opencli,~/.bash_completion.d/opencli, fish)Motivation
The previous approach parsed
.zshrcto find acompinitline and splicedfpath=(...)before it. This broke multi-line shell commands — e.g. zinit blocks wherezicompinitmatched/compinit/inside a backslash-continued line, causing the insertion to split the command block and corrupt the user's shell config (#788).Rather than trying to fix the parser (which can never be fully safe against arbitrary shell syntax), we adopt the approach used by rustup, homebrew, and other CLI tools: write the file, print the instructions, let the user decide where to put it.
Before → After
_opencli+ modified.zshrc(splice/append)_opencli+ prints fpath/compinit instructionsopencli+ modified.bashrc(append)opencli+ prints source instructionopencli.fish(no rc change)Test plan
npm install -gprints completion setup instructions for zsh.zshrcis not modified.bashrcis not modifiedCloses #788