开发者

run unison in bash script

开发者 https://www.devze.com 2023-03-16 16:43 出处:网络
Hi when I run a command on terminal like that unison dir1 dir2 -ignore \'Regex dir3\' -batch -force dir1 -confirmbigdel=false

Hi when I run a command on terminal like that

unison dir1 dir2 -ignore 'Regex dir3' -batch -force dir1 -confirmbigdel=false

it runs normally. But when I try to run it in a bash script it like that

a="-ignore 'Regex dir3'"
unison dir1 dir2 "$a" -batch -force dir1 -confirmbigdel=false

it says that

unison: unknown option `-ignore 'Regex c''

开发者_Go百科

How can I solve that problem? Thank you... .


You need to use an array instead of a string. That way, when you "dereference", the shell will see the right number of words (2).

a=( -ignore 'Regex dir3' )
unison dir1 dir2 "${a[@]}" -batch -force dir1 -confirmbigdel=false
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号