From 926a71266ea186efb8afcb5812350703f5ea76eb Mon Sep 17 00:00:00 2001 From: bcherb2 Date: Sat, 22 Aug 2026 21:58:59 -0400 Subject: [PATCH] =?UTF-8?q?feat:=20bootstrap.sh=20defaults=20to=20its=20ow?= =?UTF-8?q?n=20clone=20URL=20=E2=80=94=20one=20URL=20to=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .tests/test.sh | 17 +++++++++-------- README.md | 7 ++++--- bootstrap.sh | 22 ++++++++++------------ 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.tests/test.sh b/.tests/test.sh index a3399c0..061dd5a 100755 --- a/.tests/test.sh +++ b/.tests/test.sh @@ -1098,15 +1098,16 @@ fi printf '\n\033[1mbootstrap.sh — the first command, wrapped\033[0m\n' B=$ROOT/bootstrap.sh if sh -n "$B" 2>/dev/null; then ok "bootstrap.sh parses"; else no "bootstrap.sh has a syntax error"; fi -# The same property the phase 3 negative test asserts for the tier as a whole: -# this file ships in the public repo, so it names no real host, ever. -if grep -qEi 'djdadi|15\.204|xeta' "$B"; then no "bootstrap.sh names a real host"; else ok "bootstrap.sh names no real host"; fi -# No URL from argv, env, or a tty -> usage and exit 2, before curl runs. -rc=0; out=$(DOTFILES_URL= sh "$B" &1) || rc=$? -is "no URL anywhere is refused, not guessed" 2 "$rc" +# The tier names no real host, with one carved-out exception: this file may +# name ITS OWN clone URL (fetching it proves you know the host already). It +# must never name the endpoint, the VPS, or the private repo. +if grep -qEi 'xeta|15\.204|dotfiles-private' "$B"; then no "bootstrap.sh names a host beyond its own repo"; else ok "bootstrap.sh names nothing beyond its own repo"; fi +if grep -q 'DEFAULT_URL="https://[^"]*/dotfiles-public.git"' "$B"; then ok "…and defaults to its own clone URL"; else no "…and defaults to its own clone URL — default missing or malformed"; fi +# An explicit empty URL is an error, not a fall-through to the default: the +# caller said "this one" and named nothing. +rc=0; out=$(DOTFILES_URL= sh "$B" "" &1) || rc=$? +is "an explicit empty URL is refused, not defaulted" 2 "$rc" has "…and says how to call it" "usage:" "$out" -rc=0; out=$(sh "$B" "" &1) || rc=$? -is "an empty argument is an error too, not a prompt hang" 2 "$rc" printf '\n\033[1minteractive loop (needs a pty)\033[0m\n' if command -v fzf >/dev/null && command -v curl >/dev/null && command -v script >/dev/null; then diff --git a/README.md b/README.md index befe23d..b52028d 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,12 @@ sh -c "$(curl -fsLS get.chezmoi.io)" -- init --apply ~/.local/bin/dotup ``` -The first line is also wrapped as `bootstrap.sh` in this repo, for anyone who -can fetch it raw but cannot remember chezmoi's incantation: +The first line is also wrapped as `bootstrap.sh`, which defaults to this +repo's own clone URL — the one place in the tier a real host appears, because +fetching the file proves you already know it: ```sh -curl -fsSL /bootstrap.sh | sh -s -- +curl -fsSL /bootstrap.sh | sh ``` Two commands. The first lays down the files and clones the six externals; the diff --git a/bootstrap.sh b/bootstrap.sh index 729bf5a..65ae73b 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -4,20 +4,18 @@ # # sh bootstrap.sh # or run it bare and answer the prompt # -# The repo URL is an argument rather than a constant for the same reason the -# tests prompt for it: this tier is public and names no real host. Your own -# paste-ready line lives in the private repo's runbook. +# This tier names no real host -- with exactly one exception, and it is this +# file naming ITS OWN clone URL. The exception discloses nothing: the only way +# to fetch this script is to already know the host it names. The endpoint host +# and everything else stay out, same as everywhere else in the tier. set -u -URL=${1:-${DOTFILES_URL:-}} -# Prompt only when someone is there to answer: `curl | sh` and the test -# harness both arrive with stdin not a terminal, and must fail fast instead -# of hanging on a prompt nobody sees. -if [ -z "$URL" ] && [ -t 0 ]; then - printf 'Public repo clone URL: ' >&2 - IFS= read -r URL || : -fi -[ -n "$URL" ] || { echo "usage: bootstrap.sh " >&2; exit 2; } +DEFAULT_URL="https://git.djdadi.com/ben/dotfiles-public.git" +# An explicit argument wins outright -- including an explicit EMPTY one, which +# is an error rather than a silent fall-through to the default: the caller +# said "this one" and then named nothing. +if [ "$#" -ge 1 ]; then URL=$1; else URL=${DOTFILES_URL:-$DEFAULT_URL}; fi +[ -n "$URL" ] || { echo "usage: bootstrap.sh [public-repo-url]" >&2; exit 2; } command -v curl >/dev/null 2>&1 \ || { echo "bootstrap.sh: curl is required and not installed" >&2; exit 1; }