diff options
author | Alain Magloire <alainm@rcsm.ee.mcgill.ca> | 1999-10-06 01:13:21 +0000 |
---|---|---|
committer | Alain Magloire <alainm@rcsm.ee.mcgill.ca> | 1999-10-06 01:13:21 +0000 |
commit | d206e058e9f71d7f79bd995bceb1624f1b5cb546 (patch) | |
tree | 444d60b7f8ea714a6e0ab9715953969c67918b7c /doc/grep.texi | |
parent | 6381e78b88522d6053c3da06e5c6a1354f94cf4c (diff) | |
download | grep-d206e058e9f71d7f79bd995bceb1624f1b5cb546.tar.gz |
make egrep == grep -E.
Bugfixes
Accept a patch from Paul to make egrep == grep -E.
added new tests
* NEWS: egrep is now equivalent to `grep -E'.
The lower bound of an interval is not optional.
You can specify a matcher multiple types without error.
-u and -U are now allowed on non-DOS hosts, and have no effect.
* doc/grep.texi: Likewise.
* doc/grep.1: Likewise.
Fix some troff bugs that prevented `groff' from rendering the page.
* src/egrepmat.c, src/fgrepmat.c, src/grepmat.c (default_matcher):
Remove.
(matcher): Add.
* src/grep.h (default_matcher): Remove.
(matcher): Now exported from ?grepmat.c, not grep.c.
* src/dfa.c (lex): If { would start an invalid interval specification,
* src/grep.c (short_options): New constant.
(long_options, main): -u and -U are now supported on Unix,
with no effect.
(matcher): Removed; now defined by ?grepmat.c.
(install_matcher): Renamed from setmatcher.
(setmatcher): New function.
(usage): Report new, more uniform option scheme.
(main): Do not initialize matcher; ?grepmat.c now does this.
Rely on setmatcher to catch matcher conflicts.
Default matcher is "grep".
* src/search.c (matchers):
Remove "posix-egrep" matcher; no longer needed.
(Ecompile): Likewise.
The egrep matcher now has POSIX behavior.
* tests/bre.tests: grep '\{' is no longer an error.
Fix test for interval too large, and enable it.
* tests/ere.tests: grep -E {1 is no longer an error
Likewise for a{1, a{1a, a{1a}, a{1,x}.
Diffstat (limited to 'doc/grep.texi')
-rw-r--r-- | doc/grep.texi | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/doc/grep.texi b/doc/grep.texi index ff5cac41..557ea68d 100644 --- a/doc/grep.texi +++ b/doc/grep.texi @@ -377,7 +377,7 @@ Specifying @samp{-U} overrules this guesswork, causing all files to be read and passed to the matching mechanism verbatim; if the file is a text file with CR/LF pairs at the end of each line, this will cause some regular -expressions to fail. This option is only supported on +expressions to fail. This option has no effect on platforms other than MS-DOS and MS-Windows. @item -u @@ -391,7 +391,7 @@ Report Unix-style byte offsets. This switch causes text file, i.e. the byte offsets ignore the CR characters which were stripped off. This will produce results identical to running @sc{grep} on a Unix machine. This option has no effect unless @samp{-b} -option is also used; it is only supported on MS-DOS and +option is also used; it has no effect on platforms other than MS-DOS and MS-Windows. @item -Z @@ -542,8 +542,7 @@ by newlines, any of which is to be matched. @end table In addition, two variant programs @sc{egrep} and @sc{fgrep} are available. -@sc{egrep} is similar (but not identical) to @samp{grep -E}, and -is compatible with the historical Unix @sc{egrep}. @sc{fgrep} is the +@sc{egrep} is the same as @samp{grep -E}. @sc{fgrep} is the same as @samp{grep -F}. @node Regular Expressions, Reporting Bugs, Grep Programs, Top @@ -705,12 +704,6 @@ The preceding item is matched exactly @var{n} times. @cindex match sub-expression n or more times The preceding item is matched n or more times. -@item @{,@var{m}@} -@opindex @{,m@} -@cindex braces, first argument omitted -@cindex match sub-expression at most m times -The preceding item is optional and is matched at most @var{m} times. - @item @{@var{n},@var{m}@} @opindex @{n,m@} @cindex braces, two arguments @@ -741,8 +734,42 @@ In basic regular expressions the metacharacters @samp{?}, @samp{+}, instead use the backslashed versions @samp{\?}, @samp{\+}, @samp{\@{}, @samp{\|}, @samp{\(}, and @samp{\)}. -In @sc{egrep} the metacharacter @samp{@{} loses its special meaning; -instead use @samp{\@{}. This not true for @samp{grep -E}. +@cindex interval specifications +There is a longstanding minor compatibility problem with regular +expressions like @samp{x@{2,8@}} that use interval specifications. +Traditional @command{egrep} did not support interval specifications, but +@sc{posix} requires them, and says that the effect of regular +expressions like @samp{x@{,8@}} or @samp{(@{2,8@})} is undefined because +their interval specifications are invalid. In @command{grep} 2.3 and +earlier, @samp{grep -E} acted as @sc{posix} required, but it reported an +error when it encountered a @samp{@{} that was not the prefix of a valid +interval specification. Had @command{egrep} 2.3 been equivalent to +@samp{grep -E}, it would have broken old-fashioned scripts that assume +that @samp{@{} is not special in egrep patterns. So @command{egrep} 2.3 +and earlier did not support interval specifications, even though +@sc{posix} required it. + +This compatibility problem has been addressed by changing @samp{grep -E} +to be less pedantic about invalid interval specifications. Instead of +reporting an error, @samp{grep -E} assumes that @samp{@{} is not special +if it would be the start of an invalid interval specification. For +example, @samp{grep -E @{1} now searches for the two-character string +@samp{@{1} instead of reporting a syntax error in the regular +expression. @sc{posix} allows this behavior as an extension, and it is +more compatible with what old-fashioned scripts expect of +@command{egrep}. + +The new behavior is incompatible with the traditional behavior in the +rare cases where @sc{posix} requires it. For example, @samp{egrep +x@{5@}} is now equivalent to @samp{egrep xxxxx} as required by +@sc{posix}, whereas it formerly was equivalent to @samp{egrep +'x\@{5\@}'}. Incompatibilities like these occur only when a valid +interval specification is found, not merely when @samp{@{} is found. + +This new behavior exists only to support old scripts that do not conform +to @sc{posix}. @sc{posix} does not define the behavior of invalid +interval specifications, and other @command{grep} implementations have +differing behavior in this area, so new scripts should avoid them. @node Reporting Bugs, Concept Index, Regular Expressions, Top |