osascript -e "set x to 3"
osascript -e "if x is 5 then"
osascript -e " tell application \"System Events\" to keystroke return"
osascript -e "end if"
我得到的输出
14:14: syntax error: Expected end of line but found end of script. (-2741)
0:6: syntax error: A “if” can’t go after this “end”. (-2740)
看不出剧本有什么问题。可能是缩进的一些问题。有人在 bash 文件中使用过 osascript 吗?