我有这个运行一些 Applescript 的 bash 函数。如果我在 Applescript 编辑器或 Textmate 中运行 Applescript 部分,它可以正常工作,但在命令行上,该功能会失败......
wtf() {
osascript - <<EOF
tell application "iTerm"
tell current terminal
launch session "Railscasts"
tell the last session
write text 'echo -ne "\\e]1;$account\\a"'
end tell
end tell
end tell
EOF
}
错误是:
190:191: syntax error: Expected expression but found unknown token. (-2741)
我知道(认为)问题出在这一行的第一个 bash 转义序列上:
write text 'echo -ne "\\e]1;$account\\a"'
^
但我不知道为什么它会失败......请告诉我为什么这不起作用?
编辑1:我也试过这个,但失败了:
wtf() {
osascript - <<EOF
tell application "iTerm"
tell current terminal
launch session "Railscasts"
tell the last session
write text "echo -ne \\\"\\e]1;$account\\a\\\""
end tell
end tell
end tell
EOF
}
错误信息:
163:164: syntax error: Expected end of line but found unknown token. (-2741)