Skip to content

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

Closed

Description

@abruption

What happens

install_here() ends with:

[ -f "$SKILL_DIR/cc_peer.py" ] || fetch "$RAW/cc_peer.py" "$SKILL_DIR/cc_peer.py"

Under curl | sh, $0 is sh, so dirname gives . and src_dir becomes the current working directory — a real path, so the || src_dir="" fallback never fires. With no cc_peer.py in cwd the copy is skipped, and then the line above skips the download too, because a copy is already installed.

Nothing is fetched. The script prints installed cc-peer 0.3.0 on host and exits 0.

Why it matters now

v0.3.0 carried the command-injection fixes from #6. Anyone who followed the README's curl | sh line to pick that up got a success message and an unchanged installation — and no reason to doubt it. This is the only failure mode here that is silent.

Worse variant: if cwd happens to contain an unrelated cc_peer.py, that file gets installed instead.

Also in this file

usage() reads its own source:

sed -n '2,12p' "$0"

The header comment is 14 lines, so the output stops mid-sentence — losing "machine needs no internet access", which is the air-gapped selling point. Under curl | sh it fails outright with sed: RE error: illegal byte sequence and prints nothing, so the (try --help) hint in die() is useless on that path too.

Fix

  • Trust src_dir only when $0 is a real file; otherwise treat it as unset
  • Drop the [ -f ... ] || guard so a missing local source always fetches and overwrites
  • Replace the self-reading usage() with a heredoc — no file self-reference, so it survives curl | sh and stops depending on comment line numbers

While in here, install.sh should also reject a --host starting with - and one carrying ProxyCommand, matching check_ssh_argument() in cc_peer.py. The README claims that protection today, but install.sh has no equivalent — and --uninstall --host sends rm -rf to whatever destination it resolves.

Acceptance criteria

  • curl | sh over an existing older install actually upgrades it
  • --help prints the full header on both paths
  • An unrelated cc_peer.py in cwd is not installed
  • --host validation matches cc_peer.py
  • CI gains an install.sh smoke step — HOME=$(mktemp -d) ./install.sh && "$HOME/.local/bin/cc-peer" --version would have caught both bugs; shellcheck did not

Activity

  1. added
    bug
    on Sep 7, 2026
  2. added a commit that references this issue on Sep 8, 2026
    534fef0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions