Bash命令引用问题
发布时间:2020-12-15 21:16:43 所属栏目:安全 来源:网络整理
导读:我有这个奇怪的问题,我无法理解为什么会发生.任何bash忍者应该是小菜一碟. OPTIONS="-auto -batch -ignore 'Path one' -ignore 'Path two' -ignore 'Path three'"unison $OPTIONS a b 我希望这被翻译成…… unison -auto -batch -ignore 'Path one' -ignore
我有这个奇怪的问题,我无法理解为什么会发生.任何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 $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 FAQ条目#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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |