3

I'm using YAD to create a Yes or No dialog box in a bash script:

yad --image "dialog-question" --title "Alert" --button=gtk-yes:0 --button=gtk-no:1 --text "Are you sure you want to do this?"

If I click "No" to the question I want the bash script to terminate. If I click "Yes" I want the rest of the operations in the bash script to execute.

What code should I add to accomplish this?

1 Answer 1

3

Here a full working example :

if yad \
    --image "dialog-question" \
    --title "Alert" \
    --button=gtk-yes:0 \
    --button=gtk-no:1 \
    --text "Are you sure you want to do this?"
then
    do_the_rest...
    ...
    ...
else
    exit 1
fi
5
  • Do I replace "do the rest" with the others commands I want to execute were I to click "Yes"?
    – whitewings
    Nov 12, 2014 at 18:02
  • Duh, sure user8547 ! Nov 12, 2014 at 18:03
  • I tested it and it worked.
    – whitewings
    Nov 12, 2014 at 18:07
  • Are you surprised ? =) Nov 12, 2014 at 18:08
  • I'm too busy being sexy to be surprised.
    – whitewings
    Nov 12, 2014 at 18:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .