Skip to content

Commit b5b7b97

Browse files
committed
fix: run the native installer when piped to bash
install.sh guarded main behind [[ "${BASH_SOURCE[0]}" == "$0" ]]. Under the documented `curl … | bash` entry point bash reads the script from stdin, where BASH_SOURCE is empty and $0 is "bash": set -u aborted on the unset element, and even without -u the comparison never matched, so main never ran. Native installs and background auto-updates both failed with exit 1. install-smoke only ran bash -n and shellcheck, neither of which executes the script, so an entrypoint that never fires passed every check. Add a step that runs the piped form for real.
1 parent f06bfc0 commit b5b7b97

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pythoughts/pythinker-code": patch
3+
---
4+
5+
Fix the native install script exiting immediately without installing anything when run the documented way, `curl -fsSL … | bash`, which also broke automatic background updates for native installs.

.github/workflows/install-smoke.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ jobs:
3434
sudo apt-get install -y shellcheck
3535
shellcheck -e SC1091 apps/pythinker-web/public/install.sh
3636
37+
# `bash -n` parses the script but never runs it, so an entrypoint guard
38+
# that never fires under `curl … | bash` passes every static check. Run
39+
# the documented piped form for real; --help exits before any download.
40+
- name: Run piped installer
41+
run: |
42+
set -o pipefail
43+
out=$(cat apps/pythinker-web/public/install.sh | bash -s -- --help)
44+
case "$out" in
45+
*'native curl-bash installer'*) ;;
46+
*) echo "piped install.sh did not run main:"; echo "$out"; exit 1 ;;
47+
esac
48+
3749
- name: Check PowerShell syntax
3850
run: |
3951
pwsh -NoProfile -Command '$errs = $null; [void][System.Management.Automation.Language.Parser]::ParseFile("apps/pythinker-web/public/install.ps1", [ref]$null, [ref]$errs); if ($errs.Count) { $errs; exit 1 }'

apps/pythinker-web/public/install.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,10 @@ main() {
897897
print_done
898898
}
899899

900-
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
900+
# `curl … | bash` feeds the script over stdin, where BASH_SOURCE is empty and
901+
# $0 is "bash". Defaulting to $0 keeps the piped install (the documented entry
902+
# point) running main, still runs main when the file is executed directly, and
903+
# still skips it when the script is sourced.
904+
if [[ "${BASH_SOURCE[0]:-$0}" == "$0" ]]; then
901905
main "$@"
902906
fi

0 commit comments

Comments
 (0)