diff --git a/e2e/installer.bats b/e2e/installer.bats index a8175d95b..a19bee88a 100644 --- a/e2e/installer.bats +++ b/e2e/installer.bats @@ -67,6 +67,15 @@ run_post_install_setup() { [[ "$output" != *"Basecamp CLI"* ]] # banner would print if main ran } +@test "install.sh runs main when piped to bash" { + # Keep PATH empty so main stops at its curl prerequisite without downloading + # anything or modifying the test environment. + run bash -c "cat '$INSTALL_SH' | PATH='$BATS_TEST_TMPDIR' '$BASH'" + [[ "$status" -ne 0 ]] + [[ "$output" == *"curl is required but not installed"* ]] + [[ "$output" != *"BASH_SOURCE[0]: unbound variable"* ]] +} + @test "new binary: post_install_setup dispatches to 'setup agents', never 'setup claude'" { run_post_install_setup [[ "$status" -eq 0 ]] diff --git a/scripts/install.sh b/scripts/install.sh index 4e915c19f..c03755439 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -542,6 +542,6 @@ post_install_setup() { # Guard so sourcing the script (e.g. from tests) doesn't run the installer. # The if-form is required: `[[ … ]] && main` returns 1 when sourced, which # trips `set -e` in the sourcing shell. -if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then +if [[ "${BASH_SOURCE[0]:-$0}" == "$0" ]]; then main "$@" fi