gawk: Truth Values
1
1 6.3.1 True and False in 'awk'
1 -----------------------------
1
1 Many programming languages have a special representation for the
1 concepts of "true" and "false." Such languages usually use the special
1 constants 'true' and 'false', or perhaps their uppercase equivalents.
1 However, 'awk' is different. It borrows a very simple concept of true
1 and false from C. In 'awk', any nonzero numeric value _or_ any nonempty
1 string value is true. Any other value (zero or the null string, '""')
1 is false. The following program prints 'A strange truth value' three
1 times:
1
1 BEGIN {
1 if (3.1415927)
1 print "A strange truth value"
1 if ("Four Score And Seven Years Ago")
1 print "A strange truth value"
1 if (j = 57)
1 print "A strange truth value"
1 }
1
1 There is a surprising consequence of the "nonzero or non-null" rule:
1 the string constant '"0"' is actually true, because it is non-null.
1 (d.c.)
1