clean confirmation logic
most confirmations previously were fictious
This commit is contained in:
parent
c52ea75e20
commit
0584805720
2 changed files with 12 additions and 5 deletions
|
|
@ -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 ======
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue