Use strtonum and libutf in test(1), refactor code and manpage

and mark it as finished in README.
This commit is contained in:
FRIGN
2015-02-09 22:21:23 +01:00
parent 856c79e242
commit 360a63769c
5 changed files with 100 additions and 101 deletions

131
test.1
View File

@@ -1,75 +1,76 @@
.Dd January 30, 2015
.Dd February 9, 2015
.Dt TEST 1
.Os sbase
.Sh NAME
.Nm test
.Nd check file types and compare values
.Nd evaluate expression
.Sh SYNOPSIS
.Nm
.Ar EXPRESSION
.Ar expression
.Sh DESCRIPTION
Exit with the status determined by
.Ar EXPRESSION .
.Nm
returns the status of the
.Ar expression .
.Sh OPTIONS
.Bl -tag -width Ds
.It ! Ar EXPRESSION
invert EXPRESSION
.It Fl b Ar FILE
FILE exists and is block special
.It Fl c Ar FILE
FILE exists and is character special
.It Fl d Ar FILE
FILE exists and is a directory
.It Fl e Ar FILE
FILE exists
.It Fl f Ar FILE
FILE exists and is a regular file
.It Fl g Ar FILE
FILE exists and is set-group-ID
.It Fl h Ar FILE
FILE exists and is a symbolic link (same as
.Fl L )
.It Fl k Ar FILE
FILE exists and its sticky bit is set
.It Fl L Ar FILE
FILE exists and is a symbolic link (same as
.Fl h )
.It Fl n Ar STRING
the length of STRING is nonzero
.It Fl p Ar FILE
FILE exists and is a named pipe
.It Fl r Ar FILE
FILE exists and read permission is granted
.It Fl S Ar FILE
FILE exists and is a socket
.It Fl s Ar FILE
FILE exists and has a size greater than zero
.It Fl t Ar FD
file descriptor FD is opened on a terminal
.It Fl u Ar FILE
exists and its set-user-ID bit is set
.It Fl w Ar FILE
FILE exists and write permission is granted
.It Fl x Ar FILE
FILE exists and execute (or search) permission is granted
.It Fl z Ar STRING
the length of STRING is zero
.It s1 = s2
True if the strings s1 and s2 are identical
.It s1 != s2
True if the strings s1 and s2 are not identical
.It s1
True if s1 is not the null string
.It n1 -eq n2
True if the integers n1 and n2 are equal
.It n1 -ne n2
True if the integers n1 and n2 are not equal
.It n1 -gt n2
True if the integer n1 is greater than the integer n2
.It n1 -ge n2
True if the integer n1 is great than or equal to the integer n2
.It n1 -lt n2
True if the integer n1 is less than the integer n2
.It n1 -le n2
True if the integer n1 is less than or equal to the integer n2
.It Sy ! Ar expression
.Sy invert
.Ar expression .
.It Sy -(e | s) Ar file
.Ar file
.Sy exists
and has
.Sy arbitrary size | size greater than zero .
.It Sy -(f | d | p | hL | S | b | c) Ar file
.Ar file
.Sy exists
and is
.Sy regular file | directory | named pipe | symbolic link | socket | block special | character special .
.It Sy -(k | g | u | r | w | x) Ar file
.Ar file
.Sy exists
and is
.Sy sticky(1) | setgid(2) | setuid(4) | readable | writable | executable (or searchable) .
.It Fl t Ar fd
.Ar fd
as a file descriptor is
.Sy associated with a terminal .
.It Ar string
True if
.Ar string
is
.Sy not the null string .
.It Sy -(z | n) Ar string
True if
.Ar string
has
.Sy zero | non-zero
length.
.It Ar s1 Sy (= | !=) Ar s2
True if strings
.Ar s1
and
.Ar s2
are
.Sy identical | different .
.It Ar n1 Sy -(eq | ne | gt | ge | le | lt) Ar n2
True if integers
.Ar n1
and
.Ar n2
are
.Sy = | != | > | >= | <= | < .
.Sh EXIT STATUS
.Bl -tag -width Ds
.It 0
.Ar expression
is true.
.It 1
.Ar expression
is false.
.It > 1
An error occurred.
.El
.Sh SEE ALSO
.Xr expr 1
.Sh STANDARDS