From b035f82cc71811f36a5ee74e7fe0db02ba647edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20M=C3=BChl?= Date: Thu, 9 Apr 2026 17:21:37 +0200 Subject: [PATCH] feat(02-02): add confirmation prompt with TTY detection --- claudebox.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/claudebox.sh b/claudebox.sh index d46dce5..9ecd00e 100644 --- a/claudebox.sh +++ b/claudebox.sh @@ -74,7 +74,6 @@ if [[ -t 2 ]] && [[ "${NO_COLOR:-}" == "" ]]; then else BOLD="" RESET="" DIM="" CYAN="" YELLOW="" GREEN="" RED="" fi -export RED # used by confirmation prompt (Task 2) # Mask sensitive values (D-04) mask_value() { @@ -211,6 +210,25 @@ print_audit() { fi } +# Env audit and confirmation (D-05, D-06, D-07, UX-01, UX-02, UX-03) +if [[ "$SKIP_AUDIT" != true && "$DRY_RUN" != true ]]; then + print_audit + + # TTY check (D-06) + if [[ -t 0 ]]; then + echo -n "Proceed? [Y/n] " >&2 + read -r response < /dev/tty + response="${response,,}" # lowercase + if [[ "$response" == "n" || "$response" == "no" ]]; then + echo "Aborted." >&2 + exit 1 + fi + else + echo "${RED}Error: stdin is not a terminal. Pass --yes or -y to skip confirmation.${RESET}" >&2 + exit 1 + fi +fi + # Build sandbox command if [[ "$SHELL_MODE" == true ]]; then SANDBOX_CMD=("$SANDBOX_BASH" "${CLAUDE_ARGS[@]}")