clean confirmation logic

most confirmations previously were fictious
This commit is contained in:
do butterflies cry? 2026-01-07 22:04:16 +10:00
parent c52ea75e20
commit 0584805720
2 changed files with 12 additions and 5 deletions

View file

@ -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 ======