2015-02-09 23:33:21 +00:00
|
|
|
.Dd February 10, 2015
|
2015-01-31 13:20:02 +00:00
|
|
|
.Dt TEST 1
|
2015-01-31 19:37:03 +00:00
|
|
|
.Os sbase
|
2015-01-30 21:52:01 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm test
|
2015-02-09 21:21:23 +00:00
|
|
|
.Nd evaluate expression
|
2015-01-30 21:52:01 +00:00
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Nm
|
2015-02-09 21:21:23 +00:00
|
|
|
.Ar expression
|
2015-01-30 21:52:01 +00:00
|
|
|
.Sh DESCRIPTION
|
2015-02-09 21:21:23 +00:00
|
|
|
.Nm
|
|
|
|
returns the status of the
|
|
|
|
.Ar expression .
|
2015-01-30 21:52:01 +00:00
|
|
|
.Sh OPTIONS
|
|
|
|
.Bl -tag -width Ds
|
2015-02-09 21:21:23 +00:00
|
|
|
.It Sy ! Ar expression
|
2015-02-09 23:33:21 +00:00
|
|
|
invert
|
2015-02-09 21:21:23 +00:00
|
|
|
.Ar expression .
|
2015-02-09 23:33:21 +00:00
|
|
|
.It ( Fl e | Fl s ) Ar file
|
2015-02-09 21:21:23 +00:00
|
|
|
.Ar file
|
2015-02-09 23:33:21 +00:00
|
|
|
exists and has (any size
|
|
|
|
.Op Fl e
|
|
|
|
| non-zero size
|
|
|
|
.Op Fl s ) .
|
|
|
|
.It Sy ( Fl f | Fl d | Fl p | Fl hL | Fl S | Fl b | Fl c ) Ar file
|
2015-02-09 21:21:23 +00:00
|
|
|
.Ar file
|
2015-02-09 23:33:21 +00:00
|
|
|
exists and is a
|
|
|
|
(regular file
|
|
|
|
.Op Fl f
|
|
|
|
| directory
|
|
|
|
.Op Fl d
|
|
|
|
| named pipe
|
|
|
|
.Op Fl p
|
|
|
|
| symbolic link
|
|
|
|
.Op Fl h | Fl L
|
|
|
|
| socket
|
|
|
|
.Op Fl S
|
|
|
|
| block special
|
|
|
|
.Op Fl b
|
|
|
|
| character special
|
|
|
|
.Op Fl c ) .
|
|
|
|
.It Sy ( Fl k | Fl g | Fl u | Fl r | Fl w | Fl x ) Ar file
|
2015-02-09 21:21:23 +00:00
|
|
|
.Ar file
|
2015-02-09 23:33:21 +00:00
|
|
|
exists and has
|
|
|
|
.Xr ( sticky 1
|
|
|
|
.Op Fl k
|
|
|
|
|
|
|
|
|
.Xr setgid 2
|
|
|
|
.Op Fl g
|
|
|
|
|
|
|
|
|
.Xr setuid 4
|
|
|
|
.Op Fl u
|
|
|
|
|
|
|
|
|
.Xr read 4
|
|
|
|
.Op Fl r
|
|
|
|
|
|
|
|
|
.Xr write 2
|
|
|
|
.Op Fl w
|
|
|
|
|
|
|
|
|
.Xr execute 1
|
|
|
|
.Op Fl x )
|
|
|
|
permissions.
|
2015-02-09 21:21:23 +00:00
|
|
|
.It Fl t Ar fd
|
|
|
|
.Ar fd
|
2015-02-09 23:33:21 +00:00
|
|
|
as a file descriptor is associated with a terminal.
|
2015-02-09 21:21:23 +00:00
|
|
|
.It Ar string
|
|
|
|
True if
|
|
|
|
.Ar string
|
2015-02-09 23:33:21 +00:00
|
|
|
is not the null string.
|
|
|
|
.It Sy ( Fl z | Fl n ) Ar string
|
2015-02-09 21:21:23 +00:00
|
|
|
True if
|
|
|
|
.Ar string
|
2015-02-09 23:33:21 +00:00
|
|
|
has (zero
|
|
|
|
.Op Fl z
|
|
|
|
| non-zero
|
|
|
|
.Op Fl n )
|
2015-02-09 21:21:23 +00:00
|
|
|
length.
|
2015-02-09 23:33:21 +00:00
|
|
|
.It Ar s1 Sy ( = | != ) Ar s2
|
2015-02-09 21:21:23 +00:00
|
|
|
True if strings
|
|
|
|
.Ar s1
|
|
|
|
and
|
|
|
|
.Ar s2
|
|
|
|
are
|
2015-02-09 23:33:21 +00:00
|
|
|
(identical
|
|
|
|
.Oo Sy = Oc
|
|
|
|
| different
|
|
|
|
.Oo Sy != Oc ) .
|
|
|
|
.It Ar n1 Sy ( Fl eq | Fl ne | Fl gt | Fl ge | Fl le | Fl lt ) Ar n2
|
2015-02-09 21:21:23 +00:00
|
|
|
True if integers
|
|
|
|
.Ar n1
|
|
|
|
and
|
|
|
|
.Ar n2
|
2015-02-09 23:33:21 +00:00
|
|
|
are (=
|
|
|
|
.Op Fl eq
|
|
|
|
| !=
|
|
|
|
.Op Fl ne
|
|
|
|
| >
|
|
|
|
.Op Fl gt
|
|
|
|
| >=
|
|
|
|
.Op Fl ge
|
|
|
|
| <=
|
|
|
|
.Op Fl le
|
|
|
|
| <
|
|
|
|
.Op Fl lt ) .
|
|
|
|
.El
|
2015-02-09 21:21:23 +00:00
|
|
|
.Sh EXIT STATUS
|
|
|
|
.Bl -tag -width Ds
|
|
|
|
.It 0
|
|
|
|
.Ar expression
|
|
|
|
is true.
|
|
|
|
.It 1
|
|
|
|
.Ar expression
|
|
|
|
is false.
|
|
|
|
.It > 1
|
|
|
|
An error occurred.
|
2015-01-30 21:52:01 +00:00
|
|
|
.El
|
2015-02-09 21:21:23 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr expr 1
|
|
|
|
.Sh STANDARDS
|