bug-grep
[Top][All Lists]
Advanced

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

meaning of backslash single-quote?


From: Bruno Haible
Subject: meaning of backslash single-quote?
Date: Mon, 25 Jul 2011 00:30:35 +0200
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

Hi,

GNU grep (I tested versions 2.5, 2.7, 2.9) appears to assign a meaning to
the backslash single-quote character sequence in the argument that ought to
be a Basic Regular Expression.

$ grep --version
grep (GNU grep) 2.9
...
$ echo ' abc" ' | grep "\"\\'"
$ echo ' abc"' | grep "\"\\'"
 abc"

The regular expression consists of double-quote then backslash then
single-quote.

POSIX [1] says that such a character sequence in a BRE is undefined.
The 'grep' manual [2] says nothing about it.

As a quality of implementation issue, I would prefer to get an error message
for such an undefined BRE.

Rationale: I wanted to search for double-quote then backslash then
single-quote and got confused about the number of backslashes I had to
enter on the command-line. What I needed was "\"\\\\'". An error message
about "\"\\'" would have led me on the right path quickly.

Bruno

[1] 
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_02
[2] 
http://www.gnu.org/software/grep/manual/html_node/The-Backslash-Character-and-Special-Expressions.html
-- 
In memoriam Ezechiele Ramin <http://en.wikipedia.org/wiki/Ezechiele_Ramin>



reply via email to

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