Provide an environment variabloe, EXPR_COMPAT, which disables option
parsing for compatibility with old implementations.
This commit is contained in:
parent
ea5b39d029
commit
96ab7da385
@ -111,7 +111,9 @@ otherwise 0.
|
||||
.Pp
|
||||
Parentheses are used for grouping in the usual manner.
|
||||
.Pp
|
||||
This version of
|
||||
Unless the
|
||||
.Ev EXPR_COMPAT
|
||||
variable is defined in the process environment, this version of
|
||||
.Nm
|
||||
adheres to the
|
||||
.Tn POSIX
|
||||
@ -141,6 +143,15 @@ The syntax of the
|
||||
command in general is historic and inconvenient.
|
||||
New applications are advised to use shell arithmetic rather than
|
||||
.Nm .
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -compact -width EXPR_COMPAT
|
||||
.It Ev EXPR_COMPAT
|
||||
If set,
|
||||
.Nm
|
||||
will emulate historic
|
||||
.Nm
|
||||
implementations which did not obey the Utility Syntax Guidelines.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
.Bl -bullet
|
||||
.It
|
||||
@ -216,7 +227,10 @@ the expression is invalid.
|
||||
The
|
||||
.Nm
|
||||
utility conforms to
|
||||
.St -p1003.1-2001 .
|
||||
.St -p1003.1-2001 ,
|
||||
provided that the
|
||||
.Ev EXPR_COMPAT
|
||||
environment variable is not defined.
|
||||
.Tn POSIX
|
||||
does not specify whether arithmetic overflow is detected, nor does it specify
|
||||
the possible range of integer arguments to
|
||||
|
@ -270,14 +270,17 @@ main(int argc, char *argv[])
|
||||
int c;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
while ((c = getopt(argc, argv, "")) != -1)
|
||||
switch (c) {
|
||||
default:
|
||||
fprintf(stderr, "usage: expr [--] expression\n");
|
||||
exit(ERR_EXIT);
|
||||
}
|
||||
|
||||
av = argv + optind;
|
||||
if (getenv("EXPR_COMPAT") != NULL) {
|
||||
av = argv + 1;
|
||||
} else {
|
||||
while ((c = getopt(argc, argv, "")) != -1)
|
||||
switch (c) {
|
||||
default:
|
||||
fprintf(stderr,"usage: expr [--] expression\n");
|
||||
exit(ERR_EXIT);
|
||||
}
|
||||
av = argv + optind;
|
||||
}
|
||||
|
||||
yyparse();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user