#!/usr/bin/env bash set -euo pipefail repo="${SBP_REPO:-justypist/sbp}" branch="${SBP_BRANCH:-main}" dest="${SBP_BIN:-$HOME/.local/bin}" url="https://raw.githubusercontent.com/${repo}/${branch}/sbp" command -v curl >/dev/null 2>&1 || { echo "error: curl is required" >&2; exit 1; } command -v python3 >/dev/null 2>&1 || { echo "error: python3 is required" >&2; exit 1; } mkdir -p "$dest" tmp="$(mktemp)" trap 'rm -f "$tmp"' EXIT curl -fsSL "$url" -o "$tmp" head -n 1 "$tmp" | grep -q '^#!/usr/bin/env python3' || { echo "error: unexpected content from $url" >&2 exit 1 } chmod 755 "$tmp" mv "$tmp" "$dest/sbp" trap - EXIT echo "installed $dest/sbp" case ":$PATH:" in *":$dest:"*) ;; *) echo "note: add $dest to PATH, for example: export PATH=\"$dest:\$PATH\"" ;; esac if [ "${1:-}" = "--run" ]; then exec "$dest/sbp" install "${@:2}" fi