Assume ./program
is a program that just prints out the parameters;
$ ./program "Hello there"
Hello there
How can I properly pass arguments with quotes in from a variable? I am trying to do this;
$ args='"Hello there"'
$ echo ${args}
"Hello there"
$ ./program ${args}
Hello there # This is 1 argument
but instead, when I go through a variable the quotes in args
seem to be ignored so I get;
$ args='"Hello there"'
$ echo ${args}
"Hello there"
$ ./program ${args}
"Hello there" # This is 2 arguments
Is it possible to have bash treat the quotes as if I entered them myself in the first code block?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…