RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1108221 - grep '\w' does not match isolated Unicode characters
Summary: grep '\w' does not match isolated Unicode characters
Keywords:
Status: CLOSED DUPLICATE of bug 1159012
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: grep
Version: 7.0
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Jaroslav Škarvada
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-06-11 14:57 UTC by Martin Frodl
Modified: 2015-02-17 17:09 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-02-17 17:09:22 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Martin Frodl 2014-06-11 14:57:31 UTC
Description of problem:

With a locale set to UTF-8, the '\w' regular expression should match any character that is considered alphanumeric in Unicode. This works fine as long as there is at least one alphanumeric ASCII character on the same line.

$ echo 'hääyöaie' | grep '\w'
hääyöaie

When a line contains no alphanumeric ASCII characters, Unicode letters are not matched anymore:

$ echo 'ä' | grep '\w'
$ echo 'ä*$ ?!' | grep '\w'
$ echo 'äæøüåő' | grep '\w'
$

To fix this issue, the '\w' pattern should match Unicode letters either always (if a UTF-8 locale is set) or not at all (otherwise); it should not depend on their context.


Version-Release number of selected component (if applicable):
grep-2.16-1.el7.x86_64


How reproducible:
100%


Further information:

Note that the whole word 'hääyöaie' in the example above is highlighted in red, meaning that every single character matched the pattern '\w'. Compare with the following cases where only letters -- whether ASCII or Unicode -- and digits are matched, as opposed to the non-alphanumeric asterisk symbols. This indicates that the Unicode letters are indeed matched by the pattern under certain conditions:

$ echo 'h*ä*ä*y*ö*a*i*e' | grep '\w'
h*ä*ä*y*ö*a*i*e
^ ^ ^ ^ ^ ^ ^ ^------ highlighted
$ echo 'ä*ö*1*2*3' | grep '\w'
ä*ö*1*2*3
^ ^ ^ ^------ highlighted


Note You need to log in before you can comment on or make changes to this bug.