summaryrefslogtreecommitdiffstats
path: root/bin/expr
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>2002-05-11 03:08:12 +0000
committerwollman <wollman@FreeBSD.org>2002-05-11 03:08:12 +0000
commita04093f9b6fb49f1facd7332e64995325124f662 (patch)
tree7761504b6ed14c8a4ca61fde37f0f5039f797691 /bin/expr
parent9605f078e01c95893d87e6b0aa4ed2038c869bc6 (diff)
downloadFreeBSD-src-a04093f9b6fb49f1facd7332e64995325124f662.zip
FreeBSD-src-a04093f9b6fb49f1facd7332e64995325124f662.tar.gz
EXPR_COMPAT should imply -e, since there is no way to specify it otherwise,
and -e reflects the historic behavior of FreeBSD's expr.
Diffstat (limited to 'bin/expr')
-rw-r--r--bin/expr/expr.118
-rw-r--r--bin/expr/expr.y1
2 files changed, 18 insertions, 1 deletions
diff --git a/bin/expr/expr.1 b/bin/expr/expr.1
index 1425e00..4a978d0 100644
--- a/bin/expr/expr.1
+++ b/bin/expr/expr.1
@@ -66,7 +66,7 @@ If
.Fl e
is not specified, arithmetic operations and parsing of integer
arguments will overflow silently according to the rules of the C
-standard, and integer computations will be performed using the
+standard, using the
.Ql long
data type.
.Pp
@@ -139,6 +139,20 @@ including the one in previous versions of
will not permit this syntax.
See the examples below for portable ways to guarantee the correct
interpretation.
+The
+.Ev EXPR_COMPAT
+variable is intended for use as a transition and debugging aid, when
+.Nm
+is used in complex scripts which cannot easily be recast to avoid the
+non-portable usage.
+Defining
+.Ev EXPR_COMPAT
+also implicitly enables the
+.Fl e
+option, since this matches the historic behavior of
+.Nm
+in
+.Fx .
.Pp
The
.Nm
@@ -161,6 +175,8 @@ If set,
will emulate historic
.Nm
implementations which did not obey the Utility Syntax Guidelines.
+Implies
+.Fl e .
.El
.Sh EXAMPLES
.Bl -bullet
diff --git a/bin/expr/expr.y b/bin/expr/expr.y
index 92c0e5f..c73d853 100644
--- a/bin/expr/expr.y
+++ b/bin/expr/expr.y
@@ -280,6 +280,7 @@ main(int argc, char *argv[])
setlocale (LC_ALL, "");
if (getenv("EXPR_COMPAT") != NULL) {
av = argv + 1;
+ eflag = 1;
} else {
while ((c = getopt(argc, argv, "e")) != -1)
switch (c) {
OpenPOWER on IntegriCloud