#!/bin/sh # STET CLI installer (POSIX) — detects the platform, downloads the right static # binary, and puts it on PATH. Served with the base URL stamped in: # curl -fsSL /cli/install.sh | sh # # (This replaced a dev helper that symlinked the repo's working copy onto PATH. # Never do that: every agent on the machine then runs uncommitted code, and an # unstamped copy silently disables `stet version` and the outdated-CLI nudge. # Dev testing invokes the build directly — go build -o /tmp/stet ./cli && /tmp/stet.) set -eu BASE="https://stet.fyi" os="$(uname -s)" case "$os" in Linux) os=linux ;; Darwin) os=darwin ;; MINGW*|MSYS*|CYGWIN*) os=windows ;; *) echo "install.sh: unsupported OS '$os'" >&2; exit 1 ;; esac arch="$(uname -m)" case "$arch" in x86_64|amd64) arch=amd64 ;; aarch64|arm64) arch=arm64 ;; armv7l|armv6l) arch=arm ;; *) echo "install.sh: unsupported architecture '$arch'" >&2; exit 1 ;; esac ext="" [ "$os" = "windows" ] && ext=".exe" dest_dir="$HOME/.local/bin" dest="$dest_dir/stet$ext" url="$BASE/cli/stet/$os-$arch$ext" mkdir -p "$dest_dir" # Remove first: curl -o writes THROUGH an existing symlink, which would overwrite # whatever it points at instead of replacing the link. rm -f "$dest" echo "installing $url -> $dest" curl -fsSL --remove-on-error "$url" -o "$dest" chmod +x "$dest" case ":$PATH:" in *":$dest_dir:"*) : ;; *) echo "note: $dest_dir is not on PATH — add: export PATH=\"\$HOME/.local/bin:\$PATH\"" ;; esac printf 'installed stet ' "$dest" version