Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 182578 - sys-apps/grep-2.5.1a-r1 behaves badly when there is an '=' character in the regex
Summary: sys-apps/grep-2.5.1a-r1 behaves badly when there is an '=' character in the r...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-19 14:05 UTC by David Flogeras
Modified: 2007-06-19 19:29 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Flogeras 2007-06-19 14:05:29 UTC
I have a config file with the format:

key1 = value1
  key2   =  value2 #intentional whitespace for example

and I try to use grep (2.5.1a-r1) to check if certain keys exist with the following command:
grep '\s*key1\s*=' config.file

So in english, any whitespace, key, any whitespace, equals character

This does not work (it fails to recognize a line which should match). However changing the regex to:

grep '\s*key1\s*=*' config.file

Does work.

If I try the former regex on fedora (grep 2.5.1) it matches the pattern correctly.

Reproducible: Always

Steps to Reproduce:
1. Create a text file with a line like "gentoo = great" (without quotes)
2. grep '\s*gentoo\s*=' filename
3. grep '\s*gentoo\s*=*' filename

Actual Results:  
step two will not produce a match, while step three will
Comment 1 Harald van Dijk (RETIRED) gentoo-dev 2007-06-19 19:29:33 UTC
\s matches the lowercase letter s. To match a space character, use [[:space:]] or list the specific literal characters between [ and ]. There is no mention in the documentation of any special behaviour for \s. If Fedora's grep behaves differently, maybe they patched it, but a manually compiled grep without any patches behaves the same way for me as Gentoo's grep does.

And the reason \s*gentoo\s*=* does match your string is because it matches just "gentoo", since both the trailing letters 's' and the = are optional.