Răsfoiți Sursa

Help: Be more explicit about the behavior of if(<string>)

Craig Scott 4 ani în urmă
părinte
comite
294581a443
1 a modificat fișierele cu 13 adăugiri și 4 ștergeri
  1. 13 4
      Help/command/if.rst

+ 13 - 4
Help/command/if.rst

@@ -56,15 +56,24 @@ Basic Expressions
  ``NO``, ``FALSE``, ``N``, ``IGNORE``, ``NOTFOUND``, the empty string,
  ``NO``, ``FALSE``, ``N``, ``IGNORE``, ``NOTFOUND``, the empty string,
  or ends in the suffix ``-NOTFOUND``.  Named boolean constants are
  or ends in the suffix ``-NOTFOUND``.  Named boolean constants are
  case-insensitive.  If the argument is not one of these specific
  case-insensitive.  If the argument is not one of these specific
- constants, it is treated as a variable or string and the following
- signature is used.
+ constants, it is treated as a variable or string (see `Variable Expansion`_
+ further below) and one of the following two forms applies.
 
 
-``if(<variable|string>)``
+``if(<variable>)``
  True if given a variable that is defined to a value that is not a false
  True if given a variable that is defined to a value that is not a false
- constant.  False otherwise.  Note that macro arguments are not variables.
+ constant.  False otherwise, including if the variable is undefined.
+ Note that macro arguments are not variables.
  Environment variables also cannot be tested this way, e.g.
  Environment variables also cannot be tested this way, e.g.
  ``if(ENV{some_var})`` will always evaluate to false.
  ``if(ENV{some_var})`` will always evaluate to false.
 
 
+``if(<string>)``
+ A quoted string always evaluates to false unless:
+
+ * The string's value is one of the true constants, or
+ * Policy :policy:`CMP0054` is not set to ``NEW`` and the string's value
+   happens to be a variable name that is affected by :policy:`CMP0054`'s
+   behavior.
+
 Logic Operators
 Logic Operators
 """""""""""""""
 """""""""""""""