YAD - Bashスクリプトの終了

YAD - Bashスクリプトの終了

私はそれを使用していますBashスクリプトで「はい」または「いいえ」ダイアログボックスを作成します。

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

質問で「いいえ」をクリックすると、bashスクリプトが終了したいと思います。 「はい」をクリックすると、 bash スクリプトの残りのジョブが実行されるようになります。

これを行うには、どのコードを追加する必要がありますか?

ベストアンサー1

以下は完全な作業例です。

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

おすすめ記事