bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: sed backslash back-quote is carat (^)?


From: Pickett, David
Subject: RE: sed backslash back-quote is carat (^)?
Date: Fri, 21 Jul 2006 10:18:45 -0400

All,

I thank you for filling in my sed/regexp information.  I was mainly
concerned that it might be a bug not be a feature, as it was not mentioned
in man page sed-3.02.80/doc/sed.1 of the download.  Apparently, it is a
documentation lag.  I do not have the 'info' flavor of doc tools running
here, but see no reference to this in sed-3.02.80/doc/sed.info or
sed-3.02.80/doc/sed.texi files.  I did notice "regex(5)  [well,  one  ought
to be written... XXX]"!  If they are sed-specific extensions, I think they
should be in there somewhere.  Nothing on the GNU HTML web doc but hopeful
promises and a 1999 date:
http://www.gnu.org/software/sed/manual/html_mono/sed.html, but eventually I
googled up http://web.mit.edu/gnu/doc/html/regex_4.html

I suppose it is a hazard of having GNU-wide regexp extensions, that 'using
packages' can document them tersely by reference.  However, such
documentation does not serve the 'selected-package user' as well as those
with a complete GNU library installed.  It's be nice to insert a specific
warning and cross reference like "sed uses the extended regexp expressions
of the GNU regexp library, see <useful information to find GNU regexp
references>."

Best regards,

David

-----Original Message-----
From: address@hidden [mailto:address@hidden
Sent: Thursday, July 20, 2006 9:52 PM
To: Pickett, David; 'address@hidden'
Subject: Re: sed backslash back-quote is carat (^)?


> I used this gnu sed command, overly escaped, and got surprised (sed is
> Solaris 8 sed, gsed is gnu sed-3.02.80).  In gnu sed '\`' seems to be like
> '^', an undocumented feature:

Actually, it is a well-documented feature; you just weren't reading the
right documentation :)  In general, it is a bad idea to use more \ than
what BRE or ERE regular expression syntax requires, because it
is up to the implementation to assign additional meanings to those
additional escape sequences.  The GNU regex engine has defined \`
to mean the beginning of the whole input when requested in a
particular regex flavor, and sed chose to request it (\` is stronger
even than ^ when matching over multiple lines, since ^ only matches
beginning of individual lines).

If you have a sufficiently recent findutils installation (I'm using 4.3.0),
try 'info find.info Reference "Regular Expressions"' for a good overview
of all the various GNU regular expression flavors, including sed.  This
documents \`, and all other GNU extensions in each flavor.

-- 
Eric Blake




reply via email to

[Prev in Thread] Current Thread [Next in Thread]