test – set status according to condition|
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.
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.|
Won't complain about extraneous arguments since there may be arguments
left unprocessed by short–circuit evaluation of –a or –o.|