Index: bin/expr/expr.1 =================================================================== --- bin/expr/expr.1 +++ bin/expr/expr.1 @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 5, 2016 +.Dd August 8, 2017 .Dt EXPR 1 .Os .Sh NAME @@ -38,7 +38,7 @@ .Nd evaluate expression .Sh SYNOPSIS .Nm -.Op Fl e +.Op Fl Ee .Ar expression .Sh DESCRIPTION The @@ -67,6 +67,11 @@ and with an error status. .Pp The +.Fl E +option enables interpretation of all regular expressions as extended regular +expressions. +.Pp +The .Fl e option enables backwards compatible behaviour as detailed below. .Pp @@ -275,7 +280,9 @@ .Nm utility conforms to .St -p1003.1-2008 , -provided that backwards compatibility mode is not enabled. +provided that backwards compatibility mode is not enabled and the +.Fl E +flag is not in use. .Pp Backwards compatibility mode performs less strict checks of numeric arguments: .Bl -bullet @@ -307,8 +314,10 @@ these arguments are treated just as their respective string values. .Pp The +.Fl E +and .Fl e -flag is an extension. +flags are extensions. .Sh HISTORY An .Nm Index: bin/expr/expr.y =================================================================== --- bin/expr/expr.y +++ bin/expr/expr.y @@ -41,6 +41,7 @@ } ; char **av; +int cflags; int nonposix; struct val *result; @@ -275,14 +276,17 @@ av = argv + 1; nonposix = 1; } else { - while ((c = getopt(argc, argv, "e")) != -1) { + while ((c = getopt(argc, argv, "Ee")) != -1) { switch (c) { + case 'E': + cflags |= REG_EXTENDED; + break; case 'e': nonposix = 1; break; default: errx(ERR_EXIT, - "usage: expr [-e] expression\n"); + "usage: expr [-Ee] expression\n"); } } av = argv + optind; @@ -538,7 +542,7 @@ to_string(b); /* compile regular expression */ - if ((eval = regcomp(&rp, b->u.s, 0)) != 0) { + if ((eval = regcomp(&rp, b->u.s, cflags)) != 0) { regerror(eval, &rp, errbuf, sizeof(errbuf)); errx(ERR_EXIT, "%s", errbuf); }