巴什引用问题 [英] Bash quoting issue
本文介绍了巴什引用问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个奇怪的问题,我不明白为什么发生。这应该是任何庆典忍者的一块蛋糕。
I have this weird issue, I can't understand why is happening. It should be a piece of cake for any bash ninja.
OPTIONS="-auto -batch -ignore 'Path one' -ignore 'Path two' -ignore 'Path three'"
unison $OPTIONS a b
我希望这是翻译成...
I expected this to be translated as...
unison -auto -batch -ignore 'Path one' -ignore 'Path two' -ignore 'Path three' a b
......,只是工作。但事实并非如此。当运行完整的命令,我没有问题,齐声是确定这一点。但是,当我运行命令齐声$选项A B
,齐声抱怨:
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)
我在做什么错了?
What am I doing wrong?
推荐答案
BASH FAQ条目#50:我M试图在一个变量把一个命令,但复杂的案件总是失败!
BASH FAQ entry #50: "I'm trying to put a command in a variable, but the complex cases always fail!"
options=(-auto -batch -ignore 'Path one' ...)
unison "${options[@]}" a b
这篇关于巴什引用问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文