Fix piped installer under nounset
Merged
PR
3mo ago+10+10+01234567890123456789-1-1-0123456789
What
- Make the installer source guard tolerate an unset
BASH_SOURCE[0]when Bash reads the script from standard input. - Add a regression test that pipes the real installer into Bash without downloading or installing anything.
Why
The documented curl ... | bash installation path runs with BASH_SOURCE[0] unset. The source guard added in #558 dereferences that value while set -u is active, so the installer exits before main runs. Falling back to $0 preserves direct and piped execution while still preventing main from running when the script is sourced.
Testing
-
bats e2e/installer.bats -
bin/ci
Summary by cubic
Fix the installer so piping to bash works under set -u. The source guard now tolerates an unset BASH_SOURCE[0], so curl ... | bash runs main as expected.
- Bug Fixes
- Update guard to
[[ "${BASH_SOURCE[0]:-$0}" == "$0" ]]to handle stdin execution while still preventing execution when sourced. - Add e2e test that pipes the real installer to
bash, runs with the current$BASH, and asserts it fails on missingcurl(not on an unbound variable).
- Update guard to