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
|
||||
function seek_confirmation() {
|
||||
force=0
|
||||
echo ""
|
||||
input "$@"
|
||||
if [[ "${force}" == "1" ]]; then
|
||||
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
|
||||
function is_confirmed() {
|
||||
(($force)) && return 0;
|
||||
if [[ "${force}" == "1" ]]; then
|
||||
return 0
|
||||
else
|
||||
if [[ "$REPLY" =~ ^[Yy]$ ]]; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function is_not_confirmed() {
|
||||
|
||||
Reference in New Issue
Block a user