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" ;;