【发布时间】:2020-09-01 19:55:45
【问题描述】:
我有一个需要向其传递参数的外部可执行文件。使用 bash 脚本,我有确定这些参数的代码。一些参数可能已经转义了空格。 然后我需要执行该字符串,而不扩展每个参数。
# ... some code that determines argument string
# the following is an example of the string
ARGSTR='./executable test\ file.txt arg2=true'
exec ${ARGSTR}
我必须扩展$ARGSTR,以便我可以将参数传递给./executable,但每个参数都不应扩展。我试过引用"test file.txt",但这仍然没有将它作为一个参数传递给./executable。
有没有办法做这样的事情?
【问题讨论】:
标签: string bash command-line-arguments