mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-09 21:53:47 -05:00
Fixed '--force' function when seeking confirmation
This commit is contained in:
@@ -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() {
|
||||||
|
|||||||
Reference in New Issue
Block a user