Fix: make curl | bash install work (empty BASH_SOURCE on stdin)#2
Merged
Conversation
The installer resolved its hook sources via ${BASH_SOURCE[0]} relative to
its own file. Piped through `curl ... | bash`, the script is read from
stdin: BASH_SOURCE is empty, so under `set -u` it aborted with
"BASH_SOURCE[0]: unbound variable" and then failed to find the sibling
hooks/ directory — making the advertised one-line install impossible.
- Guard ${BASH_SOURCE[0]:-} so set -u no longer crashes on stdin.
- install_hook(): copy from a local checkout when present, otherwise
download the hook scripts from the repo.
- CLAUDE_CONTEXT_TICK_REF (default main) pins the download ref;
CLAUDE_CONTEXT_TICK_RAW_BASE overrides the base URL (mirror/tests).
- Add tests/test_install_piped.sh: hermetic regression (stdin +
file:// base, no network).
- Update README security note + CHANGELOG.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.7 (1M context) <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
The advertised one-line install never worked:
install.shlocated its hook sources via${BASH_SOURCE[0]}relative to its own file. When piped throughcurl ... | bashthe script is read from stdin — there is no file, soBASH_SOURCEis empty. Underset -u(line 14) that referencing aborts withBASH_SOURCE[0]: unbound variable, and the derivedREPO_ROOTcollapses to the parent of the caller's cwd, so the siblinghooks/lookup fails. The only working path was the "Manual Install" (clone + run).Changes
scripts/install.sh${BASH_SOURCE[0]:-}; newinstall_hook()copies from a local checkout when present, otherwise downloads the hook scripts. AddsCLAUDE_CONTEXT_TICK_REF(defaultmain) andCLAUDE_CONTEXT_TICK_RAW_BASE(mirror/test override).tests/test_install_piped.shBASH_SOURCE) and resolves downloads from the local checkout via afile://base — no network.README.mdCLAUDE_CONTEXT_TICK_REF; security note updated (it downloads two hook scripts + merges settings).CHANGELOG.mdFixed+Addedentries under[Unreleased].Risk
LOW.
uninstall.shwas unaffected (uses fixed$HOME/.claude/paths). The settings.json merge/idempotency logic is unchanged. The checkout-install path keeps copying fromhooks/exactly as before.Testing
test_install_piped.HOMEs:UserPromptSubmit+SessionEnd, exit 0.bash scripts/install.sh) → cp path, exit 0.shellcheck scripts/install.shclean.Checklist
🤖 Generated with Claude Code