EXPR_COMPAT should imply -e, since there is no way to specify it otherwise,

and -e reflects the historic behavior of FreeBSD's expr.
This commit is contained in:
Garrett Wollman 2002-05-11 03:08:12 +00:00
parent 4a21733e2d
commit 94a48596a3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=96382
2 changed files with 18 additions and 1 deletions

View File

@ -66,7 +66,7 @@ If
.Fl e .Fl e
is not specified, arithmetic operations and parsing of integer is not specified, arithmetic operations and parsing of integer
arguments will overflow silently according to the rules of the C 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 .Ql long
data type. data type.
.Pp .Pp
@ -139,6 +139,20 @@ including the one in previous versions of
will not permit this syntax. will not permit this syntax.
See the examples below for portable ways to guarantee the correct See the examples below for portable ways to guarantee the correct
interpretation. 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 .Pp
The The
.Nm .Nm
@ -161,6 +175,8 @@ If set,
will emulate historic will emulate historic
.Nm .Nm
implementations which did not obey the Utility Syntax Guidelines. implementations which did not obey the Utility Syntax Guidelines.
Implies
.Fl e .
.El .El
.Sh EXAMPLES .Sh EXAMPLES
.Bl -bullet .Bl -bullet

View File

@ -280,6 +280,7 @@ main(int argc, char *argv[])
setlocale (LC_ALL, ""); setlocale (LC_ALL, "");
if (getenv("EXPR_COMPAT") != NULL) { if (getenv("EXPR_COMPAT") != NULL) {
av = argv + 1; av = argv + 1;
eflag = 1;
} else { } else {
while ((c = getopt(argc, argv, "e")) != -1) while ((c = getopt(argc, argv, "e")) != -1)
switch (c) { switch (c) {