mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-11-15 00:05:20 +00:00
d23148604d
This is taken from NetBSD.
276 lines
6.5 KiB
Groff
276 lines
6.5 KiB
Groff
.\" Copyright (c) 1991 Regents of the University of California.
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" This code is derived from software contributed to Berkeley by
|
|
.\" the Institute of Electrical and Electronics Engineers, Inc.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
.\" must display the following acknowledgement:
|
|
.\" This product includes software developed by the University of
|
|
.\" California, Berkeley and its contributors.
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
.\" may be used to endorse or promote products derived from this software
|
|
.\" without specific prior written permission.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
.\" SUCH DAMAGE.
|
|
.\"
|
|
.\" @(#)test.1 6.6 (Berkeley) 6/8/92
|
|
.\"
|
|
.\" $Id: test.1,v 1.1 1996/02/10 08:27:32 gdr Exp $
|
|
.\"
|
|
.TH TEST 1 "Commands and Applications" "9 February 1996" "Version 1.0"
|
|
.SH NAME
|
|
test \- Condition evaluation utility.
|
|
.SH SYNOPSIS
|
|
.B test
|
|
.I expression
|
|
.SH DESCRIPTION
|
|
The
|
|
.B test
|
|
utility evaluates the expression and, if it evaluates
|
|
to true, returns a zero (true) exit status; otherwise
|
|
it returns 1 (false).
|
|
If there is no expression, test also
|
|
returns 1 (false).
|
|
.LP
|
|
All operators and flags are separate arguments to the
|
|
.B test
|
|
utility.
|
|
.LP
|
|
The following primaries are used to construct
|
|
.IR expression :
|
|
.IP "\fB-b\fR \fIfile\fR"
|
|
True if
|
|
.I file
|
|
exists and is a block special
|
|
file.
|
|
.IP "\fB-c\fR \fIfile\fR"
|
|
True if
|
|
.I file
|
|
exists and is a character
|
|
special file.
|
|
.IP "\fB-d\fR \fIfile\fR"
|
|
True if
|
|
.I file
|
|
exists and is a directory.
|
|
.IP "\fB-e\fR \fIfile\fR"
|
|
True if
|
|
.I file
|
|
exists (regardless of type).
|
|
.IP "\fB-f\fR \fIfile\fR"
|
|
True if
|
|
.I file
|
|
exists and is a regular file.
|
|
.IP "\fB-g\fR \fIfile\fR"
|
|
True if
|
|
.I file
|
|
exists and its set group ID flag
|
|
is set.
|
|
.IP "\fB-n\fR \fIstring\fR"
|
|
True if the length of
|
|
.I string
|
|
is nonzero.
|
|
.IP "\fB-p\fR \fIfile\fR"
|
|
True if
|
|
.I file
|
|
is a named pipe (FIFO).
|
|
.IP "\fB-r\fR \fIfile\fR"
|
|
True if
|
|
.I file
|
|
exists and is readable.
|
|
.IP "\fB-s\fR \fIfile\fR"
|
|
True if
|
|
.I file
|
|
exists and has a size greater
|
|
than zero.
|
|
.IP "\fB-t\fR [ \fIfile_descriptor\fR ]"
|
|
True if the file whose file descriptor number
|
|
is
|
|
.I file_descriptor
|
|
(default 1) is open and is
|
|
associated with a terminal.
|
|
.IP "\fB-u\fR \fIfile\fR"
|
|
True if
|
|
.I file
|
|
exists and its set user ID flag
|
|
is set.
|
|
.IP "\fB-w\fR \fIfile\fR"
|
|
True if
|
|
.I file
|
|
exists and is writable.
|
|
True
|
|
indicates only that the write flag is on.
|
|
The file is not writable on a read-only file
|
|
system even if this test indicates true.
|
|
.IP "\fB-x\fR \fIfile\fR"
|
|
True if
|
|
.I file
|
|
exists and is executable.
|
|
True
|
|
indicates only that the execute flag is on.
|
|
If
|
|
.I file
|
|
is a directory, true indicates that
|
|
.I file
|
|
can be searched.
|
|
.IP "\fB-z\fR \fIstring\fR"
|
|
True if the length of
|
|
.I string
|
|
is zero.
|
|
.IP "\fIstring\fR"
|
|
True if
|
|
.I string
|
|
is not the null
|
|
string.
|
|
.IP "\fIs1\fR \fB=\fR \fIs2\fR"
|
|
True if the strings
|
|
.I s1
|
|
and
|
|
.I s2
|
|
are identical.
|
|
.IP "\fIs1\fR \fB!=\fR \fIs2\fR"
|
|
True if the strings
|
|
.I s1
|
|
and
|
|
.I s2
|
|
are not identical.
|
|
.IP "\fIn1\fR \fB-eq\fR \fIn2\fR"
|
|
True if the integers
|
|
.I n1
|
|
and
|
|
.I n2
|
|
are algebraically
|
|
equal.
|
|
.IP "\fIn1\fR \fB-ne\fR \fIn2\fR"
|
|
True if the integers
|
|
.I n1
|
|
and
|
|
.I n2
|
|
are not
|
|
algebraically equal.
|
|
.IP "\fIn1\fR \fB-gt\fR \fIn2\fR"
|
|
True if the integer
|
|
.I n1
|
|
is algebraically
|
|
greater than the integer
|
|
.I n2 .
|
|
.IP "\fIn1\fR \fB-ge\fR \fIn2\fR"
|
|
True if the integer
|
|
.I n1
|
|
is algebraically
|
|
greater than or equal to the integer
|
|
.I n2 .
|
|
.IP "\fIn1\fR \fB-lt\fR \fIn2\fR"
|
|
True if the integer
|
|
.I n1
|
|
is algebraically less
|
|
than the integer
|
|
.I n2 .
|
|
.IP "\fIn1\fR \fB-le\fR \fIn2\fR"
|
|
True if the integer
|
|
.I n1
|
|
is algebraically less
|
|
than or equal to the integer
|
|
.I n2 .
|
|
.LP
|
|
These primaries can be combined with the following operators:
|
|
.IP "\fB!\fR \fIexpression\fR"
|
|
True if
|
|
.I expression
|
|
is false.
|
|
.IP "\fIexpression1\fR \fB-a\fR \fIexpression2\fR"
|
|
True if both
|
|
.I expression1
|
|
and
|
|
.I expression2
|
|
are true.
|
|
.IP "\fIexpression1\fR \fB-o\fR \fIexpression2\fR"
|
|
True if either
|
|
.I expression1
|
|
or
|
|
.I expression2
|
|
are true.
|
|
.IP "\fB\&(\fR \fIexpression\fR \fB\&)\fR"
|
|
True if
|
|
.I expression
|
|
is true.
|
|
.LP
|
|
The
|
|
.B -a
|
|
operator has higher precedence than the
|
|
.B -o
|
|
operator.
|
|
.SH GRAMMAR AMBIGUITY
|
|
The
|
|
.B test
|
|
grammar is inherently ambiguous. In order to assure a degree of consistency,
|
|
the cases described in the
|
|
.IR "POSIX 1003.2" ,
|
|
section D11.2/4.62.4, standard
|
|
are evaluated consistently according to the rules specified in the
|
|
standards document. All other cases are subject to the ambiguity in the
|
|
command semantics.
|
|
.SH GNO CAVEATS
|
|
The
|
|
.BR \-b ,
|
|
.BR \-c ,
|
|
.BR \-g ,
|
|
and
|
|
.BR \-u
|
|
operators always cause a false return value (as of GNO v2.0.4)
|
|
since block- and character-special files, and the setuid and setgid bits
|
|
are not currently available under GS/OS.
|
|
.LP
|
|
Because of the implementation of
|
|
.BR stat (2)
|
|
under GNO v2.0.4, the
|
|
.BR \-x
|
|
operator will return false if
|
|
.I file
|
|
is a directory.
|
|
.SH RETURN VALUES
|
|
The
|
|
.B test
|
|
utility exits with one of the following values:
|
|
.IP \fB0\fR
|
|
.I expression
|
|
evaluated to true.
|
|
.IP \fB1\fR
|
|
.I expression
|
|
evaluated to false or expression was missing.
|
|
.IP \fB>1\fR
|
|
An error occurred.
|
|
.SH AUTHOR
|
|
This code is derived from software contributed to Berkeley by
|
|
Kenneth Almquist, and is based on BSD
|
|
.BR test
|
|
version 5.4.
|
|
.LP
|
|
The GNO port of
|
|
.BR test
|
|
was done by Devin Reade, <gdr@myrias.com>.
|
|
.SH STANDARDS
|
|
The
|
|
.B test
|
|
function is expected to be
|
|
.I "POSIX 1003.2"
|
|
compatible.
|