From 05848057209e62e58e11dca76f27f9aea154c13d Mon Sep 17 00:00:00 2001 From: _cry64 Date: Wed, 7 Jan 2026 22:04:16 +1000 Subject: [PATCH] clean confirmation logic most confirmations previously were fictious --- ceru/libceru.sh | 16 ++++++++++++---- ceru/subcmds/new/key | 1 - 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ceru/libceru.sh b/ceru/libceru.sh index 92d21d7..f3ff6d5 100755 --- a/ceru/libceru.sh +++ b/ceru/libceru.sh @@ -68,12 +68,20 @@ function confirm-action { function confirm { confirm-action ":: Proceed? [Y/n] "; } function confirm-file-overwrite { - echo -e "${BOLD}${UNDERLINE}${BLINKFAST}${RED}WARNING!${RESET} ${YELLOW}The following files will be overwritten:${RESET}" - local ARG="" + local OVERWRITE=false + local ARG for ARG in "$@"; do - echo -e "${BOLD} • ${GREEN}${ARG}${RESET}" + if [[ -f "$ARG" ]]; then + # write info (initial) lines on first overwritable file found + if [[ "$OVERWRITE" = false ]]; then + echo -e "${BOLD}${UNDERLINE}${BLINKFAST}${RED}WARNING!${RESET} ${YELLOW}The following files will be overwritten:${RESET}" + OVERWRITE=true + fi + # list all files that require overwriting + echo -e "${BOLD} • ${GREEN}${ARG}${RESET}" + fi done - confirm + [[ "$OVERWRITE" = false ]] || confirm } # ====== Core ====== diff --git a/ceru/subcmds/new/key b/ceru/subcmds/new/key index 41b4916..e37570b 100755 --- a/ceru/subcmds/new/key +++ b/ceru/subcmds/new/key @@ -48,7 +48,6 @@ while [[ $# -gt 0 ]]; do shift FORCE=true ;; - -*) throw-badflag 1 "$ARG" ;;