From 23933b640d129fde5eef1f25a501ea9b8be90271 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 11 Jul 2008 14:11:54 +0200 Subject: [PATCH] clarify description of ^ and $ in the manual 2008-07-10 Paolo Bonzini * doc/sed-in.texi: Make the description of ^ and $ more precise. * doc/sed.texi: Regenerate. --- ChangeLog | 5 +++++ THANKS | 1 + doc/sed-in.texi | 32 +++++++++++++++++++------------- doc/sed.texi | 32 +++++++++++++++++++------------- 4 files changed, 44 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index ed5bf19..a7902f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-07-10 Paolo Bonzini + + * doc/sed-in.texi: Make the description of ^ and $ more precise. + * doc/sed.texi: Regenerate. + 2008-05-15 Paolo Bonzini * autoboot.conf: Update for newer gnulib. diff --git a/THANKS b/THANKS index e902e0b..3eeb114 100644 --- a/THANKS +++ b/THANKS @@ -7,6 +7,7 @@ Bruno Haible Chip Salzenberg Chris Weber Corinna Vinschen +Daniel R. Grayson David Eckelkamp David J. MacKenzie David Schmidt diff --git a/doc/sed-in.texi b/doc/sed-in.texi index 330854b..79bba81 100644 --- a/doc/sed-in.texi +++ b/doc/sed-in.texi @@ -210,7 +210,8 @@ then exit. @opindex --silent @cindex Disabling autoprint, from command line By default, @command{sed} prints out the pattern space -at the end of each cycle through the script. +at the end of each cycle through the script (@pxref{Execution Cycle, , +How @code{sed} works}). These options disable this automatic printing, and @command{sed} only produces output when explicitly told to via the @code{p} command. @@ -715,21 +716,26 @@ Use back references (see below). Matches any character, including newline. @item ^ -Matches the null string at beginning of line, i.e. what -appears after the circumflex must appear at the -beginning of line. @code{^#include} will match only -lines where @samp{#include} is the first thing on line---if -there are spaces before, for example, the match fails. -@code{^} acts as a special character only at the beginning -of the regular expression or subexpression (that is, -after @code{\(} or @code{\|}). Portable scripts should avoid -@code{^} at the beginning of a subexpression, though, as -@acronym{POSIX} allows implementations that treat @code{^} as -an ordinary character in that context. +Matches the null string at beginning of the pattern space, i.e. what +appears after the circumflex must appear at the beginning of the +pattern space. +In most scripts, pattern space is initialized to the content of each +line (@pxref{Execution Cycle, , How @code{sed} works}). So, it is a +useful simplification to think of @code{^#include} as matching only +lines where @samp{#include} is the first thing on line---if there are +spaces before, for example, the match fails. This simplification is +valid as long as the original content of pattern space is not modified, +for example with an @code{s} command. + +@code{^} acts as a special character only at the beginning of the +regular expression or subexpression (that is, after @code{\(} or +@code{\|}). Portable scripts should avoid @code{^} at the beginning of +a subexpression, though, as @acronym{POSIX} allows implementations that +treat @code{^} as an ordinary character in that context. @item $ -It is the same as @code{^}, but refers to end of line. +It is the same as @code{^}, but refers to end of pattern space. @code{$} also acts as a special character only at the end of the regular expression or subexpression (that is, before @code{\)} or @code{\|}), and its use at the end of a subexpression is not diff --git a/doc/sed.texi b/doc/sed.texi index 7d1d06b..09d534e 100644 --- a/doc/sed.texi +++ b/doc/sed.texi @@ -211,7 +211,8 @@ then exit. @opindex --silent @cindex Disabling autoprint, from command line By default, @command{sed} prints out the pattern space -at the end of each cycle through the script. +at the end of each cycle through the script (@pxref{Execution Cycle, , +How @code{sed} works}). These options disable this automatic printing, and @command{sed} only produces output when explicitly told to via the @code{p} command. @@ -716,21 +717,26 @@ Use back references (see below). Matches any character, including newline. @item ^ -Matches the null string at beginning of line, i.e. what -appears after the circumflex must appear at the -beginning of line. @code{^#include} will match only -lines where @samp{#include} is the first thing on line---if -there are spaces before, for example, the match fails. -@code{^} acts as a special character only at the beginning -of the regular expression or subexpression (that is, -after @code{\(} or @code{\|}). Portable scripts should avoid -@code{^} at the beginning of a subexpression, though, as -@acronym{POSIX} allows implementations that treat @code{^} as -an ordinary character in that context. +Matches the null string at beginning of the pattern space, i.e. what +appears after the circumflex must appear at the beginning of the +pattern space. +In most scripts, pattern space is initialized to the content of each +line (@pxref{Execution Cycle, , How @code{sed} works}). So, it is a +useful simplification to think of @code{^#include} as matching only +lines where @samp{#include} is the first thing on line---if there are +spaces before, for example, the match fails. This simplification is +valid as long as the original content of pattern space is not modified, +for example with an @code{s} command. + +@code{^} acts as a special character only at the beginning of the +regular expression or subexpression (that is, after @code{\(} or +@code{\|}). Portable scripts should avoid @code{^} at the beginning of +a subexpression, though, as @acronym{POSIX} allows implementations that +treat @code{^} as an ordinary character in that context. @item $ -It is the same as @code{^}, but refers to end of line. +It is the same as @code{^}, but refers to end of pattern space. @code{$} also acts as a special character only at the end of the regular expression or subexpression (that is, before @code{\)} or @code{\|}), and its use at the end of a subexpression is not