NAME
bool —
Logical expression tester
SYNOPSIS
bool |
-hVv |
bool |
[-dt] filename |
DESCRIPTION
bool is a logical expression tester. It
takes a logical expression as input, containing logical variable names,
parentheses and logical operators, and for each combination of values of
different variables outputs the values of variables and the evaluated value
of the expression, separated by TAB characters (like a TSV table).
-d- Debug mode: output extended debug information in addition to the simulation output.
-h- Show option summary.
-t- Output syntax tree instead of the simulation output. AST is output in the format which can be piped to dtree(1).
-V- Show full version information: like
-v, followed by copyright notice. -v- Show version information: program version and source git repository commit date.
Expression description language
An expression expr can be one of the following:
- ident
- Variable identifier. Identifiers consist of one or more uppercase and lowercase latin letters and digits. An identifier cannot start with a digit.
- expr | expr
- Logical OR (disjunction).
- expr & expr
- Logical AND (conjunction).
- expr ^ expr
- Logical XOR (exclusive or).
- expr => expr
- Logical implication.
- ~ expr
- Logical NOT (negation).
- ( expr )
- Parentheses (force operator precedence).
EXIT STATUS
The bool utility exits 0 on
success, and >0 if an error occurs.
For errors caused by the unsuccessful calls to libc functions setting errno, that value is returned as the exit status. Otherwise, the exit status is one of the following:
EXAMPLES
$ printf "~A1 | A2 & A3\n" | bool | tsvtable -n -saa +------------------+------------------+------------------+------------------+ |A1 |A2 |A3 |Result | |F |F |F |T | |F |F |T |T | |F |T |F |T | |F |T |T |T | |T |F |F |F | |T |F |T |F | |T |T |F |F | |T |T |T |T | +------------------+------------------+------------------+------------------+
$ printf "~A1 | A2 & A3\n" | bool -t | dtree -sa OR +--NOT | `--[ID(0) = "A1"] `--AND +--[ID(1) = "A2"] `--[ID(2) = "A3"]
AUTHORS
Strahinya Radich <sr@strahinja.org>, 2026
BUGS
Bugs can be reported using the ticket tracker at: https://todo.sr.ht/~strahinja/bool