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

 
 

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

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

Submitted by:  None
Submitted on:  Thu 12 Sep 2013 09:57:48 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

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

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup