Fixed '--force' function when seeking confirmation

This commit is contained in:
Nathaniel Landau
2015-03-31 00:31:20 -04:00
parent 470209ba7d
commit 46516b2ccb

View File

@@ -245,20 +245,26 @@ function is_os() {
# Ask the question # Ask the question
function seek_confirmation() { function seek_confirmation() {
force=0
echo "" echo ""
input "$@" input "$@"
read -p " (y/n) " -n 1 if [[ "${force}" == "1" ]]; then
echo "" notice "Forcing confirmation with '--force' flag set"
else
read -p " (y/n) " -n 1
echo ""
fi
} }
# Test whether the result of an 'ask' is a confirmation # Test whether the result of an 'ask' is a confirmation
function is_confirmed() { function is_confirmed() {
(($force)) && return 0; if [[ "${force}" == "1" ]]; then
if [[ "$REPLY" =~ ^[Yy]$ ]]; then
return 0 return 0
else
if [[ "$REPLY" =~ ^[Yy]$ ]]; then
return 0
fi
return 1
fi fi
return 1
} }
function is_not_confirmed() { function is_not_confirmed() {