Reputation: 837
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. I know there are a bunch of switches like -e or -c or -f, but when would the following code get evaluated as true?
if [ "$VAR" ]; then
echo "TRUE"
else
echo "FALSE"
fi
I'm trying to interpret a script someone wrote for me.
Upvotes: 1
Views: 1013
Reputation: 21507
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.
Upvotes: 2
Reputation: 798516
From help test
:
STRING True if string is not empty.
Upvotes: 4