Zenity 问题 - 如何使用用户输入?

Era*_*909 6 zenity

我想提出一个更进一步的问题,具体取决于您选择的答案。

我的脚本中的问题是:

zenity --question --text="Would you like to participate in a little form?" 
Run Code Online (Sandbox Code Playgroud)

_

完整脚本

zenity --question --text="Would you like to participate in a little form?" 
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

Til*_*man 8

zenity --question将在其退出代码中返回用户的答案。您可以从$?特殊变量中收集它,就像这样

zenity --question --text="Are you there?"
THERE=$?
Run Code Online (Sandbox Code Playgroud)

或者直接在这样的条件下使用它

if zenity --question --text="Do you want to answer stupid questions?"
then 
    zenity --entry --text="Why?"
fi
Run Code Online (Sandbox Code Playgroud)