summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorAlain Magloire <alainm@rcsm.ee.mcgill.ca>1999-10-12 20:41:01 +0000
committerAlain Magloire <alainm@rcsm.ee.mcgill.ca>1999-10-12 20:41:01 +0000
commitd65fb55711e5eecf14c2dbb79a1f0db19ee854e5 (patch)
tree1c38048aef381bca48007f8fa6d14a9a579e9e8f /doc
parentda75e9e83b27fe7a3f8edc8bb6df8af259fc19fe (diff)
downloadgrep-d65fb55711e5eecf14c2dbb79a1f0db19ee854e5.tar.gz
Changes buy P. E.
Changes buy P. E. * NEWS, doc/grep.1, doc/grep.texi: New option --mmap. * src/grep.c (mmap_option): New variable. (long_options, reset, usage): Add --mmap. Default is now read, not mmap. * doc/grep.1: Document -Z or --null. * doc/grep.texi: Fix texinfo glitches. POSIX -> POSIX.2 where appropriate. * doc/grep.texi: Fix texinfo glitches. POSIX -> POSIX.2 where appropriate. * acconfig.h (ssize_t): New #undef. * configure.in (AC_CHECK_TYPE): Add ssize_t. * src/grep.c (PREFERRED_SAVE_FACTOR): New macro. (reset): If the buffer has already been allocated, set bufsalloc to be bufalloc / PREFERRED_SAVE_FACTOR. This avoids problems when bufsalloc == bufalloc (possible after reading a large binary file). (reset): Use PREFERRED_SAVE_FACTOR instead of magic constant. Do not set bufbeg; nobody uses it. Always set buflim. Check for lseek error. Use SEEK_CUR, not a magic constant. (fillbuf): Return an error indication, not a count. All callers changed. Do not assume ssize_t fits in int. Use PREFERRED_SAVE_FACTOR instead of magic constant. Clean up mmap code. Do not attempt to mmap zero bytes. Check for lseek error. Use SEEK_SET, not a magic constant. Work correctly if read is interrupted. (grepfile): Work correctly if open or close is interrupted. * src/system.h (SEEK_SET, SEEK_CUR): New macros.
Diffstat (limited to 'doc')
-rw-r--r--doc/grep.155
-rw-r--r--doc/grep.texi56
2 files changed, 55 insertions, 56 deletions
diff --git a/doc/grep.1 b/doc/grep.1
index 7b627938..0cee267f 100644
--- a/doc/grep.1
+++ b/doc/grep.1
@@ -12,7 +12,7 @@
.de Id
.ds Dt \\$4
..
-.Id $Id: grep.1,v 1.6 1999/10/12 04:11:35 alainm Exp $
+.Id $Id: grep.1,v 1.7 1999/10/12 20:41:01 alainm Exp $
.TH GREP 1 \*(Dt "GNU Project"
.SH NAME
grep, egrep, fgrep \- print lines matching a pattern
@@ -234,21 +234,21 @@ option.
.TP
.BR \-s ", " \-\^\-no-messages
Suppress error messages about nonexistent or unreadable files.
-Portability note: unlike GNU
+Portability note: unlike \s-1GNU\s0
.BR grep ,
-BSD
+traditional
.B grep
-does not comply with POSIX.2, because BSD
+did not conform to \s-1POSIX.2\s0, because traditional
.B grep
-lacks a
+lacked a
.B \-q
option and its
.B \-s
-option behaves like GNU
+option behaved like \s-1GNU\s0
.BR grep 's
.B \-q
option.
-Shell scripts intended to be portable to BSD
+Shell scripts intended to be portable to traditional
.B grep
should avoid both
.B \-q
@@ -341,11 +341,11 @@ outputs a zero byte after each file name instead of the usual newline.
This option makes the output unambiguous, even in the presence of file
names containing unusual characters like newlines. This option can be
used with commands like
-.BR "find -print0" ,
-.BR "perl -0" ,
-.BR "sort -z" ,
+.BR "find \-print0" ,
+.BR "perl \-0" ,
+.BR "sort \-z" ,
and
-.B "xargs -0"
+.B "xargs \-0"
to process arbitrary file names,
even those that contain newline characters.
.PD
@@ -358,7 +358,7 @@ expressions, by using various operators to combine smaller expressions.
.B Grep
understands two different versions of regular expression syntax:
\*(lqbasic\*(rq and \*(lqextended.\*(rq In
-.RB "GNU\ " grep ,
+.RB "\s-1GNU\s0\ " grep ,
there is no difference in available functionality using either syntax.
In other implementations, basic regular expressions are less powerful.
The following description applies to extended regular expressions;
@@ -519,12 +519,35 @@ versions
and
.BR \e) .
.PP
-In
+Traditional
.B egrep
-the metacharacter
+did not support the
.B {
-loses its special meaning; instead use
-.BR \e{ .
+metacharacter, and some
+.B egrep
+implementations support
+.B \e{
+instead, so portable scripts should avoid
+.B {
+in
+.B egrep
+patterns and should use
+.B [{]
+to match a literal
+.BR { .
+.PP
+\s-1GNU\s0
+.B egrep
+attempts to support traditional usage by assuming that
+.B {
+is not special if it would be the start of an invalid interval
+specification. For example, the shell command
+.B "egrep '{1'"
+searches for the two-character string
+.B {1
+instead of reporting a syntax error in the regular expression.
+\s-1POSIX.2\s0 allows this behavior as an extension, but portable scripts
+should avoid it.
.SH DIAGNOSTICS
.PP
Normally, exit status is 0 if matches were found,
diff --git a/doc/grep.texi b/doc/grep.texi
index 34e6e2f2..ca98c128 100644
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -201,11 +201,11 @@ the first match. Also see the @samp{-s} or @samp{--no-messages} option.
@opindex --no-messages
@cindex suppress error messages
Suppress error messages about nonexistent or unreadable files.
-Portability note: unlike @sc{gnu} @command{grep}, @sc{bsd}
-@command{grep} does not comply with @sc{posix.2}, because @sc{bsd}
-@command{grep} lacks a @samp{-q} option and its @samp{-s} option behaves
+Portability note: unlike @sc{gnu} @command{grep}, traditional
+@command{grep} did not conform to @sc{posix.2}, because traditional
+@command{grep} lacked a @samp{-q} option and its @samp{-s} option behaved
like @sc{gnu} @command{grep}'s @samp{-q} option. Shell scripts intended
-to be portable to @sc{bsd} @command{grep} should avoid both
+to be portable to traditional @command{grep} should avoid both
@samp{-q} and @samp{-s} and should redirect
output to @file{/dev/null} instead.
@@ -751,42 +751,18 @@ instead use the backslashed versions @samp{\?}, @samp{\+}, @samp{\@{},
@samp{\|}, @samp{\(}, and @samp{\)}.
@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.2} 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.2} 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.2} 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.2} 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.2} requires it. For example, @samp{egrep
-x@{5@}} is now equivalent to @samp{egrep xxxxx} as required by
-@sc{posix.2}, 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.2}. @sc{posix.2} 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.
-
+Traditional @command{egrep} did not support the @samp{@{} metacharacter,
+and some @command{egrep} implementations support @samp{\@{} instead, so
+portable scripts should avoid @samp{@{} in @samp{egrep} patterns and
+should use @samp{[@{]} to match a literal @samp{@{}.
+
+@sc{gnu} @command{egrep} attempts to support traditional usage by
+assuming that @samp{@{} is not special if it would be the start of an
+invalid interval specification. For example, the shell command
+@samp{egrep '@{1'} searches for the two-character string @samp{@{1}
+instead of reporting a syntax error in the regular expression.
+@sc{posix.2} allows this behavior as an extension, but portable scripts
+should avoid it.
@node Reporting Bugs
@chapter Reporting bugs