TEST(1) — NEWS-OS Programmer’s Manual
NAME
test − condition command
SYNOPSIS
test expr
[ expr ]
DESCRIPTION
test evaluates the expression expr, and if its value is true then returns zero exit status; otherwise, a non zero exit status is returned. test returns a non zero exit if there are no arguments. When permissions are tested, the effective user ID of the process is used. Brackets used as shown in the SYNOPSIS line must be separated by field separators, normally spaces.
The following primitives are used to construct expr.
−r file true if the file exists and is readable.
−w file true if the file exists and is writable.
−x file true if the file exists and is executable.
−f file true if the file exists and is not a directory.
But in System V mode (See SYSTEM V MODE), true if file exists and is a regular file. (i.e. false if file is a character special or block special file.)
−d file true if the file exists and is a directory.
−c file true if file exists and is a character special file.
−b file true if file exists and is a block special file.
−p file true if file exists and is a named pipe (fifo).
−u file true if file exists and is its set-user-ID bit is set.
−g file true if file exists and is its set-group-ID bit is set.
−k file true if file exists and is its sticky bit is set.
−h file true if file exists and is a symbolic link.
−l string the length of string. In System V mode this option cannot be used. (See SYSTEM V MODE)
−s file true if the file exists and has a size greater than zero.
−t [ fildes ] true if the open file whose file descriptor number is fildes (1 by default) is associated with a terminal device.
−z s1 true if the length of string s1 is zero.
−n s1 true if the length of the string s1 is nonzero.
s1 = s2 true if the strings s1 and s2 are equal.
s1 != s2 true if the strings s1 and s2 are not equal.
s1 true if s1 is not the null string.
n1 −eq n2 true if the integers n1 and n2 are algebraically equal. Any of the comparisons −ne, −gt, −ge, −lt, or −le may be used in place of −eq.
These primaries may be combined with the following operators:
! unary negation operator
−a binary and operator
−o binary or operator
( expr )
parentheses for grouping.
−a has higher precedence than −o. Notice that all the operators and flags are separate arguments to test. Notice also that parentheses are meaningful to the Shell and must be escaped.
SYSTEM V MODE
If /usr/bin/sh users specify /usr/5bin before /usr/bin in their PATH environment variable, then test is selected to System V mode.
If /usr/5bin/sh is used, System V mode is always selected, no matter what is specified in PATH.
/usr/bin/test works as BSD mode.
There are two deferrences between BSD mode and System V mode. Those options work as follow in System V mode,
−f file
true if file exists and is a regular file.
−l string cannot be used.
SEE ALSO
NOTES
To execute program named test, one more / must be included in command name, because test is a built-in command of shell. For example, to execute test in the current directory, type ./test as command name.
NEWS-OSRelease 4.2.1R