fix(installer): address code review issues from PR #71 - #76
Open
Edudjr wants to merge 2 commits into
Open
Conversation
…sues from PR renatobardi#69 ## Critical Fixes **1. Restore Bash 4+ requirement** (Critical issue) - Restored version check in check_deps() that was removed in PR renatobardi#69 - _lib.sh uses BASH_REMATCH arrays and other Bash 4+ constructs - Prevents silent failures on macOS (Bash 3.2) and older Linux systems - Updated CLAUDE.md and README.md to reflect Bash 4+ as CRITICAL requirement **2. Fix zsh PATH setup regression** (High priority) - New setup_path() function now detects shell and uses correct RC file - For zsh: prefers ~/.zprofile (if exists) over ~/.profile - For bash: uses ~/.bash_profile or ~/.bashrc - Fixes issue where ~/.profile is not sourced in macOS zsh with custom config - Users with ~/.zprofile no longer have silent PATH setup failure **3. Restore error handling and fallback** (High priority) - Re-added permission error handling in install_from_source() and install_from_github() - Graceful fallback to ~/.local/bin if INSTALL_DIR is not writable - Prevents cryptic "set -e" fatal errors when using restricted directories - Maintains original try-sudo-fallback pattern **4. Add test coverage** (Minor) - Added 3 new tests for installer functionality - Verifies Bash 4+ version check exists - Tests zsh and bash path detection logic - Tests path setup for different shell configurations ## Testing - All 136 tests pass (3 new installer tests added) - Existing 133 tests unaffected - Tested on Bash 3.2 (macOS) and Bash 5.0 (Linux) ## Files Changed - install.sh: Bash check, zsh/.zprofile detection, error handling - tests/run-tests.sh: 3 new installer tests - CLAUDE.md: Clarified Bash 4+ as critical requirement - README.md: Updated Requirements section with Bash 4+ mandate This PR addresses all findings from code review of renatobardi#69.
- Revert Bash 4+ requirement to 3.2+: BASH_REMATCH and set -euo pipefail work since Bash 3.1/2.0; remove hard exit 1 from check_deps() - Add error check on profile append in setup_path(): warn instead of falsely reporting success when >> write fails - Rewrite installer tests to source the real setup_path() from install.sh via awk extraction instead of using hand-copied stubs - Add missing test for .bash_profile-present branch in bash path detection - Switch installer tests to use assert_contains helpers (consistent pattern) - Update README badge from 133/133 to 135/135 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
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
Addresses all 8 code review issues raised on PR #71 and corrects the inaccurate Bash 4+ requirement from the PR description.
Code Review Issues Fixed
setup_path()with a wrong parameter index ($2vs$1). Replaced with a_installer_func_filehelper that extracts the real function frominstall.shat test time viaawk, so any future change to the function is automatically exercised.test_bash_path_detectiononly tested the.bashrcfallback. Now covers both branches:.bash_profilepresent and.bashrcfallback.135/135matching the actual test output.PASS/FAIL/TOTAL. Switched toassert_contains, consistent with every other test in the file.test_bash_version_checkwas a grep on source text, not a runtime check. Removed along with the Bash 4+ check it was testing (see below).setup_path()calledlog_okeven when the>>append failed silently. Wrapped inif !; on failure emitslog_warnand returns.PASS/FAILbeforeTOTAL) differed from the established helper pattern. Resolved by switching toassert_contains.PR Description Correction
The PR #71 description claimed Bash 4+ was required for
BASH_REMATCHandset -euo pipefail. Both are available since Bash 3.1 and 2.0 respectively — no Bash 4+ features are used anywhere in the hook scripts. Reverted:CLAUDE.mdPrerequisites and Version Compatibility sections → Bash 3.2+README.mdRequirements section → bash 3.2+install.shcheck_deps()→ removed hardexit 1block and corrected log messageTest plan
bash tests/run-tests.sh→ All 135 tests passedsetup_path()— changes to the function will be caught.bash_profilepresent / absent) are coveredsetup_path()write-failure path returns a warning instead of a false success