I am writing a script that opens a bunch of programs. However, sometimes I only want some of the programs open, so I am using zenity question dialogs to ask whether it should open each program.
zenity --question --text "Start Firefox?"
start_firefox=$?
if [[ $start_firefox -eq 1 ]]; then
# opens Firefox...
fi
zenity --question --text "Open Dolphin?"
open_dolphin=$?
if [[ $open_dolphin -eq 0 ]]; then
directory=$(zenity --file-selection --directory)
# continues to open Dolphin...
fi
zenity --question --text "Open gedit?"
open_gedit=$?
if [[ $open_gedit -eq 0 ]]; then
# opens gedit...
fi
The problem here is if I click on No on any of the questions, or Cancel on the file selector, it exits the entire script and I can't even collect the return value of the zenity dialog. The same code works just fine if I type it in a bash shell.