Bug 1003097

Summary: expr match behaviour changed in Fedora 19.
Product: [Fedora] Fedora Reporter: Ben Greear <greearb>
Component: coreutilsAssignee: Ondrej Vasik <ovasik>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 19CC: admiller, kdudka, kzak, ooprala, ovasik, pbrady, p, pstodulk, twaugh
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-12-13 14:56:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Ben Greear 2013-08-30 18:55:36 UTC
Description of problem:

On Fedora 17 and earlier, this would set userdir equal to something
like /home/greearb/ when pwd was /home/greearb/git

On Fedora 19, userdir is empty.

PWD=$(pwd)
userdir=$(expr match "$PWD" '\(/home/[0-Z]*/\).*')

Work-around seems to be:

[[ $PWD =~ (/home/[0-Z]*/).* ]] && userdir=${BASH_REMATCH[1]}

Not sure if this is a bug in expr or my bash script, but since
it used to work and now doesn't, it might be a regression.

Version-Release number of selected component (if applicable):

coreutils 8.21-11

How reproducible:

Always.

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Ondrej Vasik 2013-09-03 12:32:17 UTC
Thanks for report, I'm able to reproduce it with coreutils-8.21, not able with coreutils-8.17 and older (so "only" F19+ systems affected). As the expr code didn't change meanwhile, I assume gnulib regexp module has some related changes. I'll try to investigate it more, unfortunately even the "debug" mode in expr was not really helpful so far.

Comment 2 Petr Stodulka 2013-12-13 14:21:32 UTC
In Fedora 17 and earlier was parsing of regexp case-insensitive, so you couldn't match only what you want.
You need:
userdir=$(expr match "$PWD" '\(/home/[0-9a-zA-Z]*/\).*')

This behaviour is expected (discussed with upstream). It's not bug.

Comment 3 Pádraig Brady 2013-12-13 14:56:06 UTC
Yes [0-Z] is a very unusual range that would not have worked in C locales anyway for example.

The behavior here is implementation defined according to POSIX.
There has been movement lately to implement "Rational Ranges" in GNU tools.

Some links:
http://sourceware.org/ml/libc-alpha/2012-12/msg00456.html
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commit;h=6410c7a6
http://lists.gnu.org/archive/html/bug-grep/2011-12/msg00003.html