From 3a30bc4d38152ee9f909ea3ad262f75281ae0438 Mon Sep 17 00:00:00 2001 From: David A. Wheeler Date: Sat, 12 Oct 2013 14:38:24 -0400 Subject: [PATCH] Modify documentation to note sed "-E" option, now in POSIX. - This modifies the sed documentation so that it clearly identifies the "-E" option for extended regular expressions (EREs) that has been added to POSIX. For years many "sed" implementations have supported EREs, but there was no standard way to request it. GNU had "-r" (but silently supported BSD "-E"), while the BSDs had "-E" (and some also supported "-r"). The POSIX committee agreed to add ERE support to sed, and they agreed on the sed option "-E" (which is consistent with the already-standardized grep option "-E"). For more see: http://austingroupbugs.net/view.php?id=528 --- doc/sed-in.texi | 15 ++++++++++++--- doc/sed.1 | 10 +++++++--- doc/sed.texi | 17 +++++++++++++---- doc/sed.x | 5 ++++- sed/sed.c | 7 ++++--- 5 files changed, 40 insertions(+), 14 deletions(-) diff --git a/doc/sed-in.texi b/doc/sed-in.texi index 40ba70b..1e356b0 100644 --- a/doc/sed-in.texi +++ b/doc/sed-in.texi @@ -318,8 +318,10 @@ follow the link and edit the ultimate destination of the link. The default behavior is to break the symbolic link, so that the link destination will not be modified. address@hidden -r address@hidden -E address@hidden -r @itemx --regexp-extended address@hidden -E @opindex -r @opindex --regexp-extended @cindex Extended regular expressions, choosing @@ -327,8 +329,15 @@ so that the link destination will not be modified. Use extended regular expressions rather than basic regular expressions. Extended regexps are those that @command{egrep} accepts; they can be clearer because they -usually have less backslashes, but are a @acronym{GNU} extension -and hence scripts that use them are not portable. +usually have less backslashes. +Historically this was a @acronym{GNU} extension, +but the @option{-E} +extension has since been added to the POSIX standard +(http://austingroupbugs.net/view.php?id=528), +so use @option{-E} for portability. +GNU sed has accepted @option{-E} as an undocumented option for years, +and *BSD seds have accepted @option{-E} for years as well, +but scripts that use @option{-E} might not port to other older systems. @xref{Extended regexps, , Extended regular expressions}. @ifset PERL diff --git a/doc/sed.1 b/doc/sed.1 index 7acbcd0..2f02e64 100644 --- a/doc/sed.1 +++ b/doc/sed.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.28. -.TH SED "1" "February 2013" "sed 4.2.2" "User Commands" +.TH SED "1" "October 2013" "sed 4.2.2" "User Commands" .SH NAME sed \- stream editor for filtering and transforming text .SH SYNOPSIS @@ -48,9 +48,10 @@ specify the desired line-wrap length for the `l' command .IP disable all GNU extensions. .HP -\fB\-r\fR, \fB\-\-regexp\-extended\fR +\fB\-E\fR, \fB\-r\fR, \fB\-\-regexp\-extended\fR .IP -use extended regular expressions in the script. +use extended regular expressions in the script +(for portability use POSIX \fB\-E\fR). .HP \fB\-s\fR, \fB\-\-separate\fR .IP @@ -367,6 +368,9 @@ and similarly for .BR \ea , .BR \et , and other sequences. +The \fI-E\fP option switches to using extended regular expressions instead; +the -E option has been supported for years by GNU sed, and is now +included in POSIX. .SH BUGS .PP E-mail bug reports to diff --git a/doc/sed.texi b/doc/sed.texi index 2bee542..eeea001 100644 --- a/doc/sed.texi +++ b/doc/sed.texi @@ -319,8 +319,10 @@ follow the link and edit the ultimate destination of the link. The default behavior is to break the symbolic link, so that the link destination will not be modified. address@hidden -r address@hidden -E address@hidden -r @itemx --regexp-extended address@hidden -E @opindex -r @opindex --regexp-extended @cindex Extended regular expressions, choosing @@ -328,8 +330,15 @@ so that the link destination will not be modified. Use extended regular expressions rather than basic regular expressions. Extended regexps are those that @command{egrep} accepts; they can be clearer because they -usually have less backslashes, but are a @acronym{GNU} extension -and hence scripts that use them are not portable. +usually have less backslashes. +Historically this was a @acronym{GNU} extension, +but the @option{-E} +extension has since been added to the POSIX standard +(http://austingroupbugs.net/view.php?id=528), +so use @option{-E} for portability. +GNU sed has accepted @option{-E} as an undocumented option for years, +and *BSD seds have accepted @option{-E} for years as well, +but scripts that use @option{-E} might not port to other older systems. @xref{Extended regexps, , Extended regular expressions}. @ifset PERL @@ -814,7 +823,7 @@ operators. @item address@hidden Matches the @var{digit}-th @code{\(@dots{}\)} parenthesized subexpression in the regular expression. This is called a @dfn{back -reference}. Subexpressions are implicitly numbered by counting +reference}. Subexpressions are implicity numbered by counting occurrences of @code{\(} left-to-right. @item \n diff --git a/doc/sed.x b/doc/sed.x index 433d52f..5ffcad4 100644 --- a/doc/sed.x +++ b/doc/sed.x @@ -4,7 +4,7 @@ sed \- a Stream EDitor .nf sed [-V] [--version] [--help] [-n] [--quiet] [--silent] [-l N] [--line-length=N] [-u] [--unbuffered] - [-r] [--regexp-extended] + [-E] [-r] [--regexp-extended] [-e script] [--expression=script] [-f script-file] [--file=script-file] [script-if-no-other-script] @@ -312,6 +312,9 @@ and similarly for .BR \ea , .BR \et , and other sequences. +The \fI-E\fP option switches to using extended regular expressions instead; +the -E option has been supported for years by GNU sed, and is now +included in POSIX. [SEE ALSO] .BR awk (1), diff --git a/sed/sed.c b/sed/sed.c index af985e6..257dd60 100644 --- a/sed/sed.c +++ b/sed/sed.c @@ -125,8 +125,9 @@ Usage: %s [OPTION]... {script-only-if-no-other-script} [input-file]...\n\ specify the desired line-wrap length for the `l' command\n")); fprintf(out, _(" --posix\n\ disable all GNU extensions.\n")); - fprintf(out, _(" -r, --regexp-extended\n\ - use extended regular expressions in the script.\n")); + fprintf(out, _(" -E, -r, --regexp-extended\n\ + use extended regular expressions in the script\n\ + (for portability use POSIX -E).\n")); #ifdef REG_PERL fprintf(out, PERL_HELP); #endif @@ -277,7 +278,7 @@ main(argc, argv) write_mode = "wb"; break; - /* Undocumented, for compatibility with BSD sed. */ + /* "-E" is in POSIX, http://austingroupbugs.net/view.php?id=528 */ case 'E': case 'r': if (extended_regexp_flags) -- 1.6.2.5