0
我在bash腳本中有一個小的osascrip行問題。 bash腳本通過Applescript的「從列表中選擇」對話框調用,然後你可以通過if [[$ * = *「Option 1 ...選擇標籤來定義選項。在bash腳本中的osascript上取消按鈕
一位朋友給了我一個osascript行,「選擇文件」對話框顯示出來,它可以用於選擇事物,但是「取消」按鈕也會觸發「選擇文件」對話框。
我覺得osascript行在末尾不完整,都OK並取消觸發選擇文件對話框。
看起來像這樣在一個bash腳本中:
#!/bin/bash
WORKDIR="$(dirname "$0")/"
STARTUPFILE="$(/usr/bin/osascript -e "tell application \"System Events\" to activate" -e "tell application \"System Events\" to set thefile to choose file with prompt \"Choose something here\"" -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")")"
if [[ $* = *"Option 1 from Applescript"* ]]; then
cp -R "$STARTUPFILE/" "somewhere else"
do other stuff with "$STARTUPFILE...
任何想法,在osascript行中缺少取消選項,以及我可以如何實現它?