diff options
author | sheldonh <sheldonh@FreeBSD.org> | 1999-08-16 09:44:09 +0000 |
---|---|---|
committer | sheldonh <sheldonh@FreeBSD.org> | 1999-08-16 09:44:09 +0000 |
commit | 90a5109c16c32f86f9a2c8968a2e4abf85d71ed3 (patch) | |
tree | 22bc48aad6566d71b90235fa534be590d589165f /bin/test/test.1 | |
parent | 122d640213334cd6872cf7247331d2c89b463b7a (diff) | |
download | FreeBSD-src-90a5109c16c32f86f9a2c8968a2e4abf85d71ed3.zip FreeBSD-src-90a5109c16c32f86f9a2c8968a2e4abf85d71ed3.tar.gz |
Replace our test(1) with NetBSD's pdksh-derived version. The code is
significantly easier to read and extend and offers a few new tests.
A few style changes taken from style(9) and OpenBSD, as well as
whitespace cleanups.
This change was discussed on freebsd-committers and freebsd-hackers
and met with approval from at least des, eivind and brian.
PR: 13091
Obtained from: NetBSD
Diffstat (limited to 'bin/test/test.1')
-rw-r--r-- | bin/test/test.1 | 91 |
1 files changed, 73 insertions, 18 deletions
diff --git a/bin/test/test.1 b/bin/test/test.1 index 45a84e3..bfe342b 100644 --- a/bin/test/test.1 +++ b/bin/test/test.1 @@ -33,20 +33,23 @@ .\" SUCH DAMAGE. .\" .\" @(#)test.1 8.1 (Berkeley) 5/31/93 -.\" $Id: test.1,v 1.7 1998/09/07 16:59:05 cracauer Exp $ +.\" $Id: test.1,v 1.8 1998/12/18 03:16:47 jkoshy Exp $ .\" .Dd May 31, 1993 .Dt TEST 1 .Os .Sh NAME -.Nm test +.Nm test , +.Nm \&[ .Nd condition evaluation utility .Sh SYNOPSIS .Nm test .Ar expression +.Nm [ +.Ar expression Cm ] .Sh DESCRIPTION The -.Nm +.Nm test utility evaluates the expression and, if it evaluates to true, returns a zero (true) exit status; otherwise it returns 1 (false). @@ -54,11 +57,11 @@ If there is no expression, test also returns 1 (false). .Pp All operators and flags are separate arguments to the -.Nm +.Nm test utility. .Pp The following primaries are used to construct expression: -.Bl -tag -width indent +.Bl -tag -width Ar .It Fl b Ar file True if .Ar file @@ -90,6 +93,14 @@ is set. True if .Ar file exists and is a symbolic link. +This operator is retained for compatibility with previous versions of +this program. Do not rely on its existence; use +.Fl L +instead. +.It Fl k Ar file +True if +.Ar file +exists and its sticky bit is set. .It Fl n Ar string True if the length of .Ar string @@ -99,25 +110,20 @@ True if .Ar file is a named pipe .Po Tn FIFO Pc . -.It Fl S Ar file -True if -.Ar file -is a socket. .It Fl r Ar file True if -.Ar file +.Ar file exists and is readable. .It Fl s Ar file True if .Ar file exists and has a size greater than zero. -.It Fl t Ar [file_descriptor] +.It Fl t Op Ar file_descriptor True if the file whose file descriptor number is .Ar file_descriptor -(default 1) is open and is -associated with a terminal. +is open and is associated with a terminal. .It Fl u Ar file True if .Ar file @@ -146,6 +152,38 @@ can be searched. True if the length of .Ar string is zero. +.It Fl L Ar file +True if +.Ar file +exists and is a symbolic link. +.It Fl O Ar file +True if +.Ar file +exists and its owner matches the effective user id of this process. +.It Fl G Ar file +True if +.Ar file +exists and its group matches the effective group id of this process. +.It Fl S Ar file +True if +.Ar file +exists and is a socket. +.It Ar file1 Fl nt Ar file2 +True if +.Ar file1 +exists and is newer than +.Ar file2 . +.It Ar file1 Fl ot Ar file2 +True if +.Ar file1 +exists and is older than +.Ar file2 . +.It Ar file1 Fl ef Ar file2 +True if +.Ar file1 +and +.Ar file2 +exist and refer to the same file. .It Ar string True if .Ar string @@ -163,6 +201,23 @@ True if the strings and .Ar \&s\&2 are not identical. +.It Ar \&s\&1 Cm \&< Ar \&s\&2 +True if string +.Ar \&s\&1 +comes before +.Ar \&s\&2 +based on the ASCII value of their characters. +.It Ar \&s\&1 Cm \&> Ar \&s\&2 +True if string +.Ar \&s\&1 +comes after +.Ar \&s\&2 +based on the ASCII value of their characters. +.It Ar \&s\&1 +True if +.Ar \&s\&1 +is not the null +string. .It Ar \&n\&1 Fl \&eq Ar \&n\&2 True if the integers .Ar \&n\&1 @@ -232,7 +287,7 @@ operator has higher precedence than the operator. .Sh GRAMMAR AMBIGUITY The -.Nm +.Nm test grammar is inherently ambiguous. In order to assure a degree of consistency, the cases described in the .St -p1003.2 , @@ -242,7 +297,7 @@ standards document. All other cases are subject to the ambiguity in the command semantics. .Sh RETURN VALUES The -.Nm +.Nm test utility exits with one of the following values: .Bl -tag -width Ds .It 0 @@ -258,7 +313,7 @@ An error occurred. .Xr sh 1 .Sh STANDARDS The -.Nm -function is expected to be +.Nm test +utility implements a superset of the .St -p1003.2 -compatible. +specification. |