NAME
test – set status according to condition |
SYNOPSIS
test expr |
DESCRIPTION
Test evaluates the expression expr. If the value is true the exit
status is null; otherwise the exit status is non–null. If there
are no arguments the exit status is non–null.
The following primitives are used to construct expr.
! unary negation operator –o binary or operator –a binary and operator; higher precedence than –o ( expr ) parentheses for grouping. The primitives –b, –u, –g, and –s return false; they are recognized for compatibility with POSIX.
Notice that all the operators and flags are separate arguments
to test. Notice also that parentheses and equal signs are meaningful
to rc and must be enclosed in quotes. |
EXAMPLES
Test is a dubious way to check for specific character strings:
it uses a process to do what an rc(1) match or switch statement
can do. The first example is not only inefficient but wrong, because
test understands the purported string "–c" as an option.
|
SOURCE
/sys/src/cmd/test.c |
SEE ALSO
rc(1) |