Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash命令引用问题_Bash_Quoting - Fatal编程技术网

Bash命令引用问题

Bash命令引用问题,bash,quoting,Bash,Quoting,我有一个奇怪的问题,我不明白为什么会发生。这对任何一个bash忍者来说都应该是小菜一碟 OPTIONS="-auto -batch -ignore 'Path one' -ignore 'Path two' -ignore 'Path three'" unison $OPTIONS a b 我以为这会被翻译成 unison -auto -batch -ignore 'Path one' -ignore 'Path two' -ignore 'Path three' a b …只要工作。但事实

我有一个奇怪的问题,我不明白为什么会发生。这对任何一个bash忍者来说都应该是小菜一碟

OPTIONS="-auto -batch -ignore 'Path one' -ignore 'Path two' -ignore 'Path three'"
unison $OPTIONS a b
我以为这会被翻译成

unison -auto -batch -ignore 'Path one' -ignore 'Path two' -ignore 'Path three' a b
…只要工作。但事实并非如此。运行完整命令时,我没有问题,unison对此没有问题。但当我运行命令
unison$OPTIONS a b
时,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常见问题解答条目#50:


现在可以了。下次提问之前,我会先看看这个常见问题。非常感谢。
options=(-auto -batch -ignore 'Path one' ...)
unison "${options[@]}" a b