我正在尝试编写一个小脚本,在执行 svn diff 时启动 Beyond Compare。到目前为止,它一直运行正常:
open -a /Applications/Beyond\ Compare.app "$6" "$7"
为了获得完整的功能,我需要添加带有连字符(-,破折号,减号)的参数
open -a /Applications/Beyond\ Compare.app "$6" "$7" -title1="$3" -title2="$5" -readonly
但是当我这样做时,open 命令会将连字符解释为其自身的标志并退出:
open: invalid option -- i
usage: ...
我尝试“引用”整个命令或转义选项。我应该怎么做才能获得额外的功能?
答案1
请参阅打开的手册页:
--args
All remaining arguments are passed to the opened application in the argv parameter to
main(). These arguments are not opened or interpreted by the open tool.
因此,你的命令看起来应该是这样的:
open -a /Applications/Beyond\ Compare.app "$6" "$7" --args -title1="$3" -title2="$5" -readonly