我有这个奇怪的问题,我不明白为什么会发生。 它应该是任何bash忍者一块蛋糕。
OPTIONS="-auto -batch -ignore 'Path one' -ignore 'Path two' -ignore 'Path three'" unison $OPTIONS ab
我预计这将被翻译为…
unison -auto -batch -ignore 'Path one' -ignore 'Path two' -ignore 'Path three' ab
…只是工作。 但事实并非如此。 当运行完整的命令,我没有任何问题,统一就可以了。 但是当我运行命令unison $OPTIONS ab
,unison抱怨:
Usage: unison [options] or unison root1 root2 [options] or unison profilename [options] For a list of options, type "unison -help". For a tutorial on basic usage, type "unison -doc tutorial". For other documentation, type "unison -doc topics". unison was invoked incorrectly (too many roots)
我究竟做错了什么?
BASH FAQ条目#50: “我试图把一个命令放在一个变量中,但复杂的情况总是失败的!”
options=(-auto -batch -ignore 'Path one' ...) unison "${options[@]}" ab