[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
grep incorrect results with pattern ending in "\$"?
From: |
Elliott Hughes |
Subject: |
grep incorrect results with pattern ending in "\$"? |
Date: |
Wed, 9 Jan 2002 15:33:31 -0000 |
using the following file:
% cat ~/playground/dollars
this has one dollar $ here
this has two dollars $ here and $ here
this has three dollars $ here, $ here and $ here
this has two dolalrs $ here and $ here
this has one dollar $ here
i find unexpected results from:
% grep "\$.*\$.*\$" ~/playground/dollars
this has two dollars $ here and $ here
this has three dollars $ here, $ here and $ here
this has two dolalrs $ here and $ here
this happens both with grep 2.4.2 and 2.5e, though i'd expect the pattern
only to match the middle of these three lines, it being the only one with
three literal $ characters. of course, all three lines have two literal $
characters and an end of line, so it looks as if the final \$ is being
interpreted as a simple $ instead.
i had a quick look at the source, and the following part of lib/regexp.c
would look suspect, but it isn't even compiled, and regex_compile isn't
referenced anywhere:
[regex_compile]
case '$':
{
if ( /* If at end of pattern, it's an operator. */
p == pend
/* If context independent, it's an operator. */
|| syntax & RE_CONTEXT_INDEP_ANCHORS
/* Otherwise, depends on what's next. */
|| at_endline_loc_p (p, pend, syntax))
BUF_PUSH (endline);
else
goto normal_char;
}
break;
the man page's section on "obsolete (``basic'') regular expressions" says
(in English) something along these lines too, so maybe it's somehow relevant
to the problem.
--elliott
*********************************************************************
This e-mail and any attachment is confidential. It may only be read, copied and
used by the intended recipient(s). If you are not the intended recipient(s),
you may not copy, use, distribute, forward, store or disclose this e-mail or
any attachment. If you are not the intended recipient(s) or have otherwise
received this e-mail in error, you should destroy it and any attachment and
notify the sender by reply e-mail or send a message to address@hidden
*********************************************************************
- grep incorrect results with pattern ending in "\$"?,
Elliott Hughes <=