更新时间:2023-11-09 23:31:04
使用数组;这就是为什么引入它们的原因.
Use an array; this is why they were introduced.
FOO="ghi"
# Contains one element, but not the literal quotes
DEFAULTS=(--param="abc def $FOO")
# command gets 1 argument, the single element of the array
/some/command "${DEFAULTS[@]}"
# Two elements
DEFAULTS=(--param="abc def $FOO" --other="foo bar")
# command gets 2 arguments
/some/command "${DEFAULTS[@]}"