Bug 143105

Summary: grep fails to find a match when it should
Product: [Fedora] Fedora Reporter: David Alden <alden>
Component: grepAssignee: Tim Waugh <twaugh>
Status: CLOSED NOTABUG QA Contact: Mike McLean <mikem>
Severity: medium Docs Contact:
Priority: medium    
Version: 3   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-12-17 12:18:23 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Alden 2004-12-16 15:42:55 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3)
Gecko/20040922

Description of problem:
Hi,
  I was having trouble with the /etc/init.d/autofs script not setting
the timeout correctly.  I believe I've traced it down to the following
line:

if echo "$options" | grep -qE -- '\B-(t\b|-timeout\b=)' ;

It seems that this works fine in FC2, but not in FC3.


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

How reproducible:
Always

Steps to Reproduce:
1. options="--timeout=600"
2. if echo "$options" | /bin/grep -qE -- '\B-(t\b|-timeout\b=)' ; 
then echo yes; else echo no; fi


Actual Results:  no

Expected Results:  yes

Additional info:

This script works fine on FC2 and RHEL 3U3

Comment 1 Tim Waugh 2004-12-17 12:18:23 UTC
It is correct that no match is found:

==>
#include <error.h>
#include <regex.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>

void r_error (int e, regex_t *rc)
{
        char msg[200];
        regerror (e, rc, msg, sizeof (msg));
        msg[sizeof (msg) - 1] = '\0';
        error (1, 0, "%s", msg);
}

int main ()
{
        int e;
        regex_t rc;
        if ((e = regcomp (&rc, "\\B-(t\\b|-timeout\\b=)", REG_EXTENDED)) != 0)
                r_error (e, &rc);
        else if ((e = regexec (&rc, "--timeout=500", 0, NULL, 0)) != 0)
                r_error (e, &rc);
        return 0;
}
<==

$ make re
cc     re.c   -o re
$ ./re
./re: No match


Comment 2 David Alden 2004-12-17 12:29:21 UTC
Thanks.  :-)  I guess I'll file this as a bug for the autofs folks.