gpt4 book ai didi

Bash 命令引用问题

转载 作者:行者123 更新时间:2023-11-29 09:10:24 26 4
gpt4 key购买 nike

我有这个奇怪的问题,我不明白为什么会这样。对于任何 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 常见问题条目 #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

关于Bash 命令引用问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14564250/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com