feat(02-02): add confirmation prompt with TTY detection

This commit is contained in:
Christopher Mühl 2026-04-09 17:21:37 +02:00
parent 1c986d22b8
commit b035f82cc7
No known key found for this signature in database
GPG key ID: 925AC7D69955293F

View file

@ -74,7 +74,6 @@ if [[ -t 2 ]] && [[ "${NO_COLOR:-}" == "" ]]; then
else else
BOLD="" RESET="" DIM="" CYAN="" YELLOW="" GREEN="" RED="" BOLD="" RESET="" DIM="" CYAN="" YELLOW="" GREEN="" RED=""
fi fi
export RED # used by confirmation prompt (Task 2)
# Mask sensitive values (D-04) # Mask sensitive values (D-04)
mask_value() { mask_value() {
@ -211,6 +210,25 @@ print_audit() {
fi 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 # Build sandbox command
if [[ "$SHELL_MODE" == true ]]; then if [[ "$SHELL_MODE" == true ]]; then
SANDBOX_CMD=("$SANDBOX_BASH" "${CLAUDE_ARGS[@]}") SANDBOX_CMD=("$SANDBOX_BASH" "${CLAUDE_ARGS[@]}")