Index

Boolean

A truth or false value.

Input Format:
true or false

Binary Operators:
a & b
Boolean AND: This evaluates to true if both a and b are true. Otherwise it evaluates to false.
a | b
Boolean OR: This evaluates to true if either of a and b are true. Otherwise it evaluates to false.

Unary Operators:
!a
Boolean NOT. This evaluates to true if a is false, otherwise it evaluates to false. This operator has higher precedence than either of the binary operators.

Examples:
The first example always prints It's true..
 if(true) {
   print "It's true.\n"
 }
The second example shows how a boolean expression can be used to test a number of conditions at once. It also shows how parentheses can be used to force a particular logical order of evaluation. The example halts script execution for at least a minute. Thereafter the script will continue if a user sends a quit signal or the time reaches 03:44 LST.
  until $elapsed >= 1m &
        ($after_time(03:44,LST) | $signaled(quit))
Details:
Boolean expressions are parsed from left to right. Unary ! operators have the highest precedence, so they are applied to their operands first. Binary & and | operators both have equal precedence, so each is applied to the result of the expression to its left and the next operand to its right.

For example, the following two expressions are equivalent:

  until true | false & true | false & false

  until (((true | false) & true) | false) & false
If in doubt, use parenthesis to force the desired ordering.

Martin Shepherd (3-Mar-1999)