What does ${VARIABLE+x} mean in bash?
本问题已经有最佳答案,请猛点这里访问。
我遇到过在if条件下使用此语法的代码:
1 2 3 | if [ ! -z ${VARIABLE+x} ]; then some commands here fi |
它是否测试非空变量?如果是,它与
参见
${parameter:+word} Use Alternate Value. If
parameter is null or unset, nothing is substituted, otherwise the expansion ofword is substituted.
在同一节中有几段:
Omitting the colon results in a test only
for a parameter that is unset.