拥有代码:
if [ 0 ]
then
echo "0 is true."
else
echo "0 is false."
fi
结果为何echo "0 is true.
???这是否意味着bash评估0
(零位)为true
?
0
(零位)为true
?是的。
[ str ]
检查是否str
为非空。这不要紧,如果str
是0
,它仍然会被非emptyness评估。
在
test
和[
内建评估使用基于参数个数一组规则的条件表达式。0个参数
The expression is false.
1个论点
The expression is true if and only if the argument is not null.
源测试
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句