【发布时间】:2011-05-17 13:59:12
【问题描述】:
我对 bash 脚本中的 osascrip 行有一个小问题。 bash 脚本通过 Applescript 的“从列表中选择”对话框调用,然后您可以通过 if [[ $* = *"Option 1... 选择标签定义选项。
朋友给了我 osascript 行,“选择文件”对话框出现,它可以用于选择内容,但是“取消”按钮也会触发“选择文件”对话框。
我觉得 osascript 行在接近尾声的地方不完整,因为 OK 和 cancel 都触发了选择文件对话框。
在 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 行中哪里缺少取消选项以及如何实现它吗?
【问题讨论】:
标签: macos bash dialog applescript osascript