#!/usr/bin/env bash # Shared "type X to confirm" prompt for scripts/proxmox/create-proxmox-resource.sh # (--modify, and replacing an existing --allow-duplicate-host resource) and # scripts/secrets/sync-host-keys.sh (--regenerate-all-keys) -- three destructive # confirmations that all work the same way (echo the expected value back # exactly), kept in one place so the prompt/comparison logic can't drift. # Source alongside env.sh: # source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib/confirm.sh" # # Deliberately does NOT print anything on mismatch or decide exit-vs-return # -- callers vary on both (a top-level script exits, a subcommand function # returns; wording differs too), so that stays at the call site. # confirm_typed # Prints via `read -rp`, then reports (via exit status) whether the # typed input matched exactly. confirm_typed() { local expected="$1" prompt="$2" input read -rp "$prompt" input [[ "$input" == "$expected" ]] }