comment ask_* functions properly
continuous-integration/laminar-eldarion Build failed with exit code 123 after 3 seconds Details

Ref 
https://starbeamrainbowlabs.com/blog/article.php?article=posts/499-whiptail.html
This commit is contained in:
Starbeamrainbowlabs 2022-04-30 15:03:51 +01:00
parent 7e47d23a28
commit 8220c62233
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
1 changed files with 18 additions and 0 deletions

View File

@ -46,12 +46,20 @@ fi
###############################################################################
# Asks the user a yes/no question.
# $1 The question to ask the user.
# Returns 0 if the answer was yes, or 1 if the answer was no.
ask_yesno() {
local question="$1";
whiptail --title "Step ${step_current} / ${step_max}" --yesno "${question}" 40 8;
return "$?"; # Not actually needed, but best to be explicit
}
# Asks the user for a string of text.
# $1 The window title.
# $2 The question to ask.
# $3 The default text value.
# Returns the answer as a string on the standard output.
ask_text() {
local title="$1";
local question="$2";
@ -59,6 +67,12 @@ ask_text() {
whiptail --title "${title}" --inputbox "${question}" 10 40 "${default_text}" 3>&1 1>&2 2>&3;
return "$?"; # Not actually needed, but best to be explicit
}
# Asks the user for a password.
# $1 The window title.
# $2 The question to ask.
# $3 The default text value.
# Returns the answer as a string on the standard output.
ask_password() {
local title="$1";
local question="$2";
@ -66,6 +80,10 @@ ask_password() {
whiptail --title "${title}" --passwordbox "${question}" 10 40 "${default_text}" 3>&1 1>&2 2>&3;
return "$?"; # Not actually needed, but best to be explicit
}
# Asks the user to choose at most 1 item from a list of items.
# $1 The window title.
# $2..$n The items that the user must choose between.
# Returns the chosen item as a string on the standard output.
ask_multichoice() {
local title="$1"; shift;
local args=();