[英]In bash what does if [ “$VAR” ] mean
I understand how the if function works in bash, but the problem is that I don't get what it means if you aren't comparing it with something. 我了解if函数如何在bash中工作,但是问题是,如果您不将它与某些东西进行比较,我将无法理解它的含义。 I know there are a bunch of switches like -e or -c or -f, but when would the following code get evaluated as true? 我知道有一堆类似-e或-c或-f的开关,但是下面的代码何时会被评估为true?
if [ "$VAR" ]; then
echo "TRUE"
else
echo "FALSE"
fi
I'm trying to interpret a script someone wrote for me. 我正在尝试解释某人为我编写的脚本。
从help test
:
STRING True if string is not empty.
I think it's the following: 我认为是这样的:
-n STRING
the length of STRING is nonzero
STRING equivalent to -n STRING
Just the test for non-empty value. 只是测试非空值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.