Skip to content

fix: make curl|sh re-run upgrade instead of silently succeeding - #34

Merged
abruption merged 2 commits into
mainfrom
fix/23-install-curl-pipe
Sep 8, 2026
Merged

abruption merged 2 commits into
mainfrom
fix/23-install-curl-pipe

Conversation

@abruption

Copy link
Copy Markdown
Owner

Problem

Running curl -fsSL .../install.sh | sh a second time installs nothing and reports success:

  1. $0 is sh when piped, so dirname gives cwd — no project files there
  2. If files already exist at the destination, neither copy nor fetch runs
  3. usage() reads $0 with sed, which fails on a pipe
  4. --host values are not validated (unlike cc_peer.py's check_ssh_argument)
  5. remote_run() also assumes $0 is a file

Fix

  • Detect piped execution with [ -f "$0" ] and set src_dir=""
  • Always copy or fetch — never skip because files already exist
  • Replace usage() sed with a heredoc
  • Add validate_host() matching cc_peer.py's injection checks
  • remote_run() fetches to a temp dir when source files aren't available

CI

Added install-smoke job: fresh install → verify → re-run upgrade → uninstall.

Closes #23

Four problems when install.sh runs via curl|sh:

1. $0 is 'sh', so dirname gives cwd — if cwd has no cc_peer.py and
   the destination already has one, neither copy nor fetch runs.
   Fix: detect piped execution with [ -f "$0" ] and always fetch.

2. Existing files at the destination skip the fetch, so re-running
   never upgrades. Fix: always copy or fetch, never skip.

3. usage() reads $0 with sed, which fails on a pipe.
   Fix: replace with a heredoc.

4. --host values are not validated against injection (cc_peer.py has
   check_ssh_argument, install.sh did not). Fix: add validate_host().

5. remote_run() also assumed $0 was a file — now fetches to a temp
   dir when running from a pipe.

Also adds an install-smoke CI job that verifies fresh install,
re-run upgrade, and uninstall.

Closes #23
Put *permitlocalcommand* before *localcommand* — the longer pattern
must come first or shellcheck SC2221/SC2222 flags the shorter one as
both always-overriding and never-matching.
@abruption
abruption merged commit 534fef0 into main Sep 8, 2026
7 checks passed
@abruption
abruption deleted the fix/23-install-curl-pipe branch September 8, 2026 00:52
@abruption abruption mentioned this pull request Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

install.sh: re-running curl | sh installs nothing and reports success

1 participant