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行中缺少取消选项,以及我可以如何实现它?