2016-02-27 148 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的數據 - 這是我想要的