I try to make a script bash app with the help of Zenity.
https://help.gnome.org/users/zenity/stable/index.html.en
It works properly, however I encounter a problem ...
Here is my code:
#!/bin/bash
APP_NAME="bealeCrypter"
function select_letter () {
letter=("FALSE" "1" "Treasury location" "none"
"FALSE" "2" "Treasury contents" "yes"
"FALSE" "3" "Treasury beneficiaries" "none")
LETTER_FILES=$(zenity --list \
--width=430 \
--height=235 \
--title="$APP_NAME" \
--text="What letter do you want to $1 ?" \
--checklist \
--multiple \
--column=Selection \
--column=Letter \
--column=Description \
--column=Decrypted \
"${letter[@]}")
if [ $? -eq 0 ]; then
if [ -z "$LETTER_FILES" ]; then
select_letter "$1"
fi
else
app_main
fi
}
function select_letter_options () {
letter_options=("TRUE" "1" "Get the number of characters"
"TRUE" "2" "Get the smallest number"
"TRUE" "3" "Get the biggest number")
LETTER_OPTIONS=$(zenity --list \
--width=350 \
--height=210 \
--hide-header \
--title="$APP_NAME" \
--text="Choose the analyze letter options :" \
--checklist \
--multiple \
--column=Selection \
--column=Id \
--column=Description \
--hide-column=2 \
"${letter_options[@]}")
if [ $? -eq 0 ]; then
if [ -z "$LETTER_OPTIONS" ]; then
select_letter_options
fi
else
app_main
fi
}
function app_main () {
menu=("1" "Analyze a Letter")
SELECTION=$(zenity --list \
--width=350 \
--height=210 \
--hide-header \
--title="$APP_NAME" \
--text="What to do ?" \
--column=Id \
--column=Selection \
--hide-column=1 \
--cancel-label=Quit \
"${menu[@]}")
if [ $? -eq 0 ]; then
case "$SELECTION" in
1) select_letter "analyze"
select_letter_options
;;
*) app_main
esac
echo -e "LETTER: $LETTER_FILES\nKEY: $KEY_FILES\nLETTER_OPTIONS: $LETTER_OPTIONS\nKEY_OPTIONS: $KEY_OPTIONS"
else
exit 0
fi
}
app_main
Here is my problem, When I select the following menus/button (in this specific order):
- Analyze a Letter
- Cancel
- Analyze a Letter
- Select checkbox 1, 2 or 3 and OK
- Select options and OK
the option window opens twice after the validation OK, I don't understand why?
Here is a video demo:
I specify that if I do not make a Cancel (point #2) it works correctly.
How is it possible?
I tried to empty the variables before recalling the function but the result and always identical, I do not understand?
Does anyone have an explanation for this?