Add Rust toolchain installers and shell-detection hardening#228
Open
kigster wants to merge 2 commits into
Open
Add Rust toolchain installers and shell-detection hardening#228kigster wants to merge 2 commits into
kigster wants to merge 2 commits into
Conversation
- bin/rust-install: bootstraps rustup + stable Rust toolchain - bin/rust-install-tools: installs curated Rust CLI/TUI tools via cargo-binstall - lib/color.sh: detect runtime shell via $ZSH_VERSION/$BASH_VERSION instead of $SHELL (login shell), and stop exec'ing from a sourced library - init.sh: unalias find/ls in main flow so user aliases don't leak into Bashmatic internals - .vscode/settings.json: add RUSTUP to cSpell dictionary - CLAUDE.md: minor heading tweak
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.
Add Rust toolchain installers and shell-detection hardening
Summary
Adds two new user-facing executables —
bin/rust-installandbin/rust-install-tools— that provide an opinionated, idempotent installation flow for the Rust toolchain (rustup+cargo) and a curated set of modern Rust-based CLI/TUI tools (installed viacargo-binstallso users don't compile everything from source). Also hardens shell detection inlib/color.shand removes a pair of stray aliases (find,ls) ininit.shthat could leak from a user's interactive shell into sourced scripts.Description
New executables
bin/rust-install— bootstrapsrustupand the stable Rust toolchain. Self-installs Bashmatic if it isn't present, re-execs under modern Bash when invoked from macOS's stock Bash 3, and uses Bashmatic'srun/output primitives for consistent, colorful progress reporting.bin/rust-install-tools— installs a curated set of Rust CLI/TUI tools, skipping anything already present. For each missing tool, prints anh2bgbanner describing what the tool does and then installs it viacargo-binstall(with a source-build fallback for tools without prebuilt artifacts).Both scripts follow the Bashmatic conventions documented in
CLAUDE.md:.shextension onbin/files./bin/bash(Bash 3).initrather than poking at internals.Library changes
lib/color.sh— replaces${SHELL}-based shell detection (which reads the login shell, not the currently executing shell) with${ZSH_VERSION}/${BASH_VERSION}detection. Picks the correcttypeset -gx/declare -g/declareform for the actual runtime. Avoidsexec'ing into a different shell from a sourced library, which would break bothbin/*scripts and interactive zsh sessions.init.sh— addsunalias find 2>/dev/nullandunalias ls 2>/dev/nullnear the top of the main flow so user aliases (commonlyls=eza,find=fd) don't poison Bashmatic's internal command invocations.Incidental
.vscode/settings.json— addsRUSTUPto the cSpell dictionary.CLAUDE.md— minor heading tweak.Motivation
The Rust ecosystem now hosts a number of best-in-class replacements for traditional Unix tools (e.g.
ripgrep,fd,bat,eza,zoxide,bottom,dust,procs,delta,tokei). Bashmatic already ships installers for Ruby, Node, and PostgreSQL tooling; adding a Rust installer rounds out the developer-bootstrap story so a fresh machine can be brought to a "Bashmatic + a useful CLI toolbelt" state with two commands.The
color.shandinit.shfixes are prerequisites surfaced while developing the new scripts: without correct shell detection incolor.shthe new scripts fail when invoked from zsh, and without theunaliascalls ininit.shan aliasedfindorlsin the user's environment causes confusing failures inside the installers.Testing
bin/rust-installon a clean macOS account; verifiedrustup,cargo, and the stable toolchain installed correctly and the script is idempotent on a second run.bin/rust-install-toolsafterrust-install; confirmed all listed tools install viacargo-binstall, the per-tool banner renders, and re-running the script reports each tool as already present and exits cleanly.bin/specs— no regressions from thelib/color.sh/init.shchanges.bin/rust-installandbin/rust-install-toolsboth correctly re-exec under Bash 4+ when launched from/bin/bashon macOS.Backwards Compatibility
lib/color.sh: the new detection path is strictly broader — it now correctly handles zsh and Bash 3, where the old${SHELL}check could pick the wrongdeclareform. Callers that previously set${GLOBAL}themselves are unaffected (the new code unconditionally sets it based on detected runtime, matching prior intent).init.sh: the twounaliascalls are scoped to the script's own subshell and run with2>/dev/null, so users with no such aliases see no behavior change.bin/executables don't shadow any existing command names.Scalability & Performance Impact
None — the library changes are constant-time and run once at source time. The new executables are user-invoked installers; their cost is dominated by network and disk operations from
rustup/cargo-binstall.Code Quality Analysis
run-mediated command execution,usage-style help, and use of Bashmatic's output helpers (h1,h2bg,inf,ok:/not-ok:).lib/color.shnow carries a short comment explaining why${SHELL}is the wrong knob and why this library must notexec, addressing a subtle bug class that would otherwise reappear..shextensions onbin/executables.