diff options
author | Garrett Wollman <wollman@FreeBSD.org> | 2002-03-22 20:38:44 +0000 |
---|---|---|
committer | Garrett Wollman <wollman@FreeBSD.org> | 2002-03-22 20:38:44 +0000 |
commit | f477880a4fc51bf79f1ceaf4cb67e99b51e90b00 (patch) | |
tree | 8ede1855becd0ae14b5007aaac965ad033a1caa5 | |
parent | fe9c2732d1932a99d12621f34a7fb4ad286b8b78 (diff) |
Notes
-rw-r--r-- | bin/expr/expr.1 | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/bin/expr/expr.1 b/bin/expr/expr.1 index 2c4fb7922e07..fed0d30dd90a 100644 --- a/bin/expr/expr.1 +++ b/bin/expr/expr.1 @@ -142,14 +142,14 @@ command in general is historic and inconvenient. New applications are advised to use shell arithmetic rather than .Nm . .Sh EXAMPLES -.Bl -enum +.Bl -bullet .It The following example (in .Xr sh 1 syntax) adds one to the variable -.Va a . +.Va a : .Dl a=$(expr $a + 1) -.Li +.It This will fail if the value if .Va a is a negative number. @@ -159,7 +159,7 @@ from being interpreted as options to the .Nm command, one might rearrange the expression: .Dl a=$(expr 1 + $a) -.Li +.It More generally, parenthesize possibly-negative values: .Dl a=$(expr \e( $a \e) + 1) .It @@ -175,7 +175,8 @@ The .Li // characters resolve this ambiguity. .Dl expr \*q//$a\*q \&: '.*/\e(.*\e)' -.It +.El +.Pp The following examples output the number of characters in variable .Va a . Again, if @@ -183,13 +184,15 @@ Again, if might begin with a hyphen, it is necessary to prevent it from being interpreted as an option to .Nm . +.Bl -bullet +.It If the .Nm command conforms to .St -p1003.1-2001 , this is simple: .Dl expr -- \*q$a\*q \&: \*q.*\*q -.Li +.It For portability to older systems, however, a more complicated command is required: .Dl expr \e( \*qX$a\*q \&: \*q.*\*q \e) - 1 |