clean confirmation logic
most confirmations previously were fictious
This commit is contained in:
parent
b366820ddf
commit
e807e39676
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 { confirm-action ":: Proceed? [Y/n] "; }
|
||||||
|
|
||||||
function confirm-file-overwrite {
|
function confirm-file-overwrite {
|
||||||
echo -e "${BOLD}${UNDERLINE}${BLINKFAST}${RED}WARNING!${RESET} ${YELLOW}The following files will be overwritten:${RESET}"
|
local OVERWRITE=false
|
||||||
local ARG=""
|
local ARG
|
||||||
for ARG in "$@"; do
|
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
|
done
|
||||||
confirm
|
[[ "$OVERWRITE" = false ]] || confirm
|
||||||
}
|
}
|
||||||
|
|
||||||
# ====== Core ======
|
# ====== Core ======
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@ while [[ $# -gt 0 ]]; do
|
||||||
shift
|
shift
|
||||||
FORCE=true
|
FORCE=true
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-*)
|
-*)
|
||||||
throw-badflag 1 "$ARG"
|
throw-badflag 1 "$ARG"
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue