On 2/17/11 10:28 AM, Greg Wooledge wrote: > On Thu, Feb 17, 2011 at 05:07:40PM +0200, Pierre Gaston wrote: >> On Thu, Feb 17, 2011 at 4:56 PM, Clark J. Wang <dearv...@gmail.com> wrote: >>> The point is: ``Any part of the pattern may be quoted to force it to be >>> matched as a string.'' And backslash is one of bash's quoting chars. > >> aaah well the "it" in "force it" is the part, not the whole pattern. so if >> you do \.. the first . is a litteral dot, the second one matches any char. > > I think you're all missing what Clark's question actually is. Consider > this: > > imadev:~$ cat <<\EOF >> $PATH >> EOF > $PATH > > The use of a backslash in front of one of the characters of the > here-document's sentinel word is considered "quoting". And because the > sentinel word is "quoted", parameter expansions in the body are not done. > > Clark is asking why the use of a backslash before a character on the > right-hand-side of =~ is not considered "quoting" the same way it is when > doing it to a here-document's sentinel word.
How is it different? Backslash removes any special meaning from the following character. When used in a pattern context, that means that any backslash-quoted special matching character loses its special meaning, and is matched as a literal character. Quoting `a' and `.' in a regexp does the same thing: forces them to be matched exactly as `a' and `.'. Maybe if the man page had read "...to force the quoted portion to be matched as a string" this could have been avoided. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/