From 7160d3c6a5d09e08a346bff92e6f5e14370759e3 Mon Sep 17 00:00:00 2001 From: dkoao Date: Thu, 26 Sep 2019 22:34:54 +0000 Subject: [PATCH] Add a Yes/No function --- setup/functions.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/setup/functions.sh b/setup/functions.sh index 3bb96b7a..1dfe55ae 100644 --- a/setup/functions.sh +++ b/setup/functions.sh @@ -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.