Add a Yes/No function

This commit is contained in:
dkoao 2019-09-26 22:34:54 +00:00
parent 8984180787
commit 7160d3c6a5
1 changed files with 11 additions and 0 deletions

View File

@ -158,6 +158,17 @@ function message_box {
dialog --title "$1" --msgbox "$2" 0 0
}
function yesno_box {
# yesno_box "title" "prompt" VARIABLE
# The exit code resembles the user's input and will be stored in the variable VARIABLE
# Temporarily turn off 'set -e' because we need the dialog return code
declare -n result=$3
set +e
dialog --stdout --title "$1" --yesno "$2" 0 0
result=$?
set -e
}
function input_box {
# input_box "title" "prompt" "defaultvalue" VARIABLE
# The user's input will be stored in the variable VARIABLE.