Document the new, less restrictive, behavior of the matching operator.

This commit is contained in:
J.T. Conklin 1993-10-04 22:07:27 +00:00
parent 4a13ab7c12
commit d8c21a3e8a

View File

@ -1,3 +1,5 @@
.\" -*- nroff -*-
.\"
.\" Copyright (c) 1993 Winning Strategies, Inc.
.\" All rights reserved.
.\"
@ -26,7 +28,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $Header: /b/source/CVS/src/bin/expr/expr.1,v 1.1 1993/07/20 20:16:26 jtc Exp $
.\" $Id: expr.1,v 1.5 1993/10/04 22:06:59 jtc Exp $
.\"
.Dd July 3, 1993
.Dt EXPR 1
@ -65,7 +67,8 @@ if neither expression evaluates to an empty string or zero;
otherwise, returns zero.
.It Ar expr1 Li "{=, >, >=, <, <=, !=}" Ar expr2
Returns the results of integer comparision if both arguments are integers;
otherwise, returns the results of lexical comparison.
otherwise, returns the results of string comparison using the locale-specific
collation sequence.
The result of each comparison is 1 if the specified relation is true,
or 0 if the relation is false.
.It Ar expr1 Li "{+, -}" Ar expr2
@ -80,19 +83,19 @@ operator matches
against
.Ar expr2 ,
which must be a regular expression. The regular expression is anchored
to the begining of the string with an invisible
.Dq ^ ,
therefore
.Dq ^
is not a special character.
to the begining of the string with an implicit
.Dq ^ .
.Pp
If the pattern contains at lest one regular expression
subexpression
If the match succeeds and the pattern contains at least one regular
expression subexpression
.Dq "\e(...\e)" ,
the string corresponding to
.Dq "\e1"
is returned;
otherwise the matching operator returns the number of characters matched.
If the match fails and the pattern contains a regular expression subexpression
the null string is returned;
otherwise 0.
.El
.Pp
Parentheses are used for grouping in the usual manner.
@ -114,7 +117,7 @@ The following example returns the number of characters in variable a.
The
.Nm expr
utility exits with one of the following values:
.Bl -tag -width Ds
.Bl -tag -width Ds -compact
.It 0
the expression is neither an empty string nor 0.
.It 1
@ -125,7 +128,5 @@ the expression is invalid.
.Sh STANDARDS
The
.Nm expr
utility
is expected to be
.St -p1003.2
compatible.
utility conforms to
.St -p1003.2 .