我有两个可能相关的问题。首先,我的返回值显然没有设置为结果变量。其次, --button1 标志及其相关文本实际上显示在 --items 列表中。我已经尝试了所有可能的 "$result" == "#" 场景 - 引号、无引号和混合引号,但我仍然得到不同的结果。
#!/bin/bash
CD="/Applications/CocoaDialog.app/Contents/MacOS/CocoaDialog"
result=`$CD standard-dropdown --title "Database Tasks" --text "What would you like
to
do?"
--items "Clear Pending Commands" "Clear Verify Signature" "Show Processlist" --button1 "OK"`
if [ "$result" == 0 ]; then
echo "Clearing commands"
elif [ "$result" == 1 ]; then
echo "Verifying"
elif [ "$result" == 2 ]; then
echo "Process"
fi