buggrep - Bugs: bug #40009, Unexpected grep behavior with dot...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #40009: Unexpected grep behavior with dot and negated character classes, check POSIX-compatibility

Submitter:  None
Submitted:  Thu 12 Sep 2013 09:57:48 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  eggert
Open/Closed:  Closed

Sat 04 Jul 2015 03:12:55 AM UTC, comment #3: 

Paul fixed this with the following commit:

 http://git.sv.gnu.org/cgit/grep.git/commit/?id=0e8fda0d880cccd0

Jim Meyering <meyering>
Group administrator
Thu 12 Sep 2013 10:26:09 AM UTC, comment #2: 

One more,

# This matches
echo $'xxx 12 \x82' | grep -a -v -E -e '^\w{3} [01](\s|\S)*$' | xxd

# This does not
echo $'xxx 12 \x82' | grep -a -v -E -e '^\w{3} [0-1](\s|\S)*$' | xxd

So it seems that when using (\s|\S) at the end of the line, then [01] is not the same as [0-1] before the (\s|\S) sequence.

Roman <ait>
Thu 12 Sep 2013 10:21:47 AM UTC, comment #1: 

I did some more testing and found, that there might be something fundamentally wrong, e.g. [0-9] could be made to not match 1

# This doesn't match (1 is not in [0-9])
echo $'xxx 12 \x82' | grep -a -v -E -e '^\w{3} [0-9](\s|\S)*$' | xxd
# This matches, 1 equals literal one
echo $'xxx 12 \x82' | grep -a -v -E -e '^\w{3} 1(\s|\S)*$' | xxd

Roman <ait>
Thu 12 Sep 2013 09:57:48 AM UTC, original submission:  

I did not find a free copy of the standard (http://standards.ieee.org/findstds/standard/1003.1-2008.html) to look it up myself, but at least behavior seems unexpected when using '.' match with grep:

dd if=/dev/urandom bs=1k count=10 > /tmp/x

# This will most likely return output while I would expect to return none, since . should match anything than newline, hence any line is matched.
grep -a -v -E -e '^.*$' /tmp/x

# So perhaps . does not match all characters except newline, then I would expect this to react the same:
grep -a -v -E -e '^(\s|\S)*$' /tmp/x

# And also this
grep -a -v -E -e '^(x|[^x])*$' /tmp/x

# But those two behave differently

I'm not sure if this is according to specification. If yes, perhaps man-page change with explanation would be fine (since standard specification seems not open to public for free)


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by meyering (Posted a comment)
  • -email is unavailable- added by ait (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-07-04 meyering StatusNone Fixed
        Assigned toNone eggert
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code