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