Add an exit option to ask dialog
This commit is contained in:
parent
85151e1de6
commit
a0fdbe0149
1 changed files with 3 additions and 2 deletions
|
@ -68,14 +68,15 @@ ask() {
|
||||||
dialog_options="$dialog_options\n [$options_count] $option"
|
dialog_options="$dialog_options\n [$options_count] $option"
|
||||||
done;
|
done;
|
||||||
IFS=
|
IFS=
|
||||||
|
dialog_options="$dialog_options\n [0] Exit"
|
||||||
|
|
||||||
printf "%s" "$question" >&2
|
printf "%s" "$question" >&2
|
||||||
printf "%b" "$dialog_options" >&2
|
printf "%b" "$dialog_options" >&2
|
||||||
printf "\n%s" "Choose an option [1-$options_count] " >&2
|
printf "\n%s" "Choose an option number: " >&2
|
||||||
read -r read_answer
|
read -r read_answer
|
||||||
answer="$(echo "$read_answer" | xargs)"
|
answer="$(echo "$read_answer" | xargs)"
|
||||||
|
|
||||||
if [ "$answer" -gt 0 ] 2> /dev/null && [ "$answer" -le $options_count ]; then
|
if [ "$answer" -ge 0 ] 2> /dev/null && [ "$answer" -le $options_count ]; then
|
||||||
echo "$answer"
|
echo "$answer"
|
||||||
else
|
else
|
||||||
log debug "[ask] Invalid choice"
|
log debug "[ask] Invalid choice"
|
||||||
|
|
Loading…
Reference in a new issue