2016-02-27 146 views
0

我使用Yad作为简单的界面。按下按钮时提交表单值

我遇到的问题是,如果我在字段本身按Enter键,则标准输出具有用户字段的值。 但是,如果我按下“保存”按钮,那么在标准输出中没有任何内容。

这是剧本!

res=$(yad \ 
--width=600 \ 
--title="Config" \ 
--text="COnfiguration options" \ 
--form \ 
--field="User" \ 
--button="Save:1" \ 
--button="Cancel:2" \ 
--center) 

ret=$? 
echo $ret 
echo $res 
+0

您编辑删除右括号。 –

+0

感谢您指出,修正 – Merc

回答

0

我应该学会如何阅读手册页的最后一行...

即使退出代码意味着打印结果,奇数只返回退出代码。

只要做到:

res=$(yad \ 
--width=600 \ 
--title="Config" \ 
--text="COnfiguration options" \ 
--form \ 
--field="User" \ 
--button="Save:2" \ 
--button="Cancel:1" \ 
--center) 

ret=$? 
echo $ret 
echo $res 

我一定要得到一个退出代码0和2的数据 - 这是我想要的