Module Name: src Committed By: rillig Date: Sat Mar 15 16:02:53 UTC 2025
Modified Files: src/bin/expr: expr.1 Log Message: expr.1: sync with latest changes, improve wording To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/bin/expr/expr.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/expr/expr.1 diff -u src/bin/expr/expr.1:1.38 src/bin/expr/expr.1:1.39 --- src/bin/expr/expr.1:1.38 Sun Aug 28 10:48:16 2022 +++ src/bin/expr/expr.1 Sat Mar 15 16:02:53 2025 @@ -1,6 +1,6 @@ -.\" $NetBSD: expr.1,v 1.38 2022/08/28 10:48:16 hgutch Exp $ +.\" $NetBSD: expr.1,v 1.39 2025/03/15 16:02:53 rillig Exp $ .\" -.\" Copyright (c) 2000,2003 The NetBSD Foundation, Inc. +.\" Copyright (c) 2000, 2003, 2025 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd August 23, 2016 +.Dd March 15, 2025 .Dt EXPR 1 .Os .Sh NAME @@ -35,15 +35,15 @@ .Nd evaluate expression .Sh SYNOPSIS .Nm -.Ar expression +.Ar operand ... .Sh DESCRIPTION The .Nm -utility evaluates -.Ar expression -and writes the result on standard output. +utility evaluates the expression consisting of the +.Ar operand +arguments and writes the result on standard output. .Pp -All operators are separate arguments to the +Each operand is a separate arguments to the .Nm utility. Characters special to the command interpreter must be escaped. @@ -56,22 +56,25 @@ Returns the evaluation of .Ar expr1 if it is neither an empty string nor zero; otherwise, returns the evaluation of -.Ar expr2 . +.Ar expr2 +if it is not empty; +otherwise, returns zero. .It Ar expr1 Li & Ar expr2 Returns the evaluation of .Ar expr1 if neither expression evaluates to an empty string or zero; otherwise, returns zero. .It Ar expr1 Li "{=, >, >=, <, <=, !=}" Ar expr2 -Returns the results of integer comparison if both arguments are integers; -otherwise, returns the results of string comparison using the locale-specific -collation sequence. +Returns the result of the integer comparison if both arguments are integers; +otherwise, returns the result of the 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 -Returns the results of addition or subtraction of integer-valued arguments. +Returns the result of addition or subtraction of integer-valued arguments. .It Ar expr1 Li "{*, /, %}" Ar expr2 -Returns the results of multiplication, integer division, or remainder of integer-valued arguments. +Returns the result of multiplication, integer division, or remainder +of integer-valued arguments. .It Ar expr1 Li \&: Ar expr2 The .Dq \&: @@ -79,7 +82,7 @@ operator matches .Ar expr1 against .Ar expr2 , -which must be a regular expression. +the latter must be a regular expression. The regular expression is anchored to the beginning of the string with an implicit .Dq ^ . @@ -91,8 +94,8 @@ 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; +If the match fails and the pattern contains a regular expression subexpression, +the empty string is returned; otherwise 0. .It "( " Ar expr No " )" Parentheses are used for grouping in the usual manner. @@ -208,7 +211,7 @@ expr "//$a" : '.*/\e(.*\e)' According to .St -p1003.2 , .Nm -has to recognize special option +has to recognize the special option .Dq -- , treat it as a delimiter to mark the end of command line options, and ignore it. @@ -217,7 +220,7 @@ Some implementations do not recognize it at all; others might ignore it even in cases where doing so results in syntax error. -There should be same result for both following examples, +There should be the same result for both following examples, but it might not always be: .Bl -enum -compact -offset indent .It