Bug 1011663 - grep -r behavior different between RHEL6 and Fedora 20
grep -r behavior different between RHEL6 and Fedora 20
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: grep (Show other bugs)
20
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Jaroslav Škarvada
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-24 14:23 EDT by Alexander Todorov
Modified: 2013-09-27 06:10 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-09-27 06:10:55 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Alexander Todorov 2013-09-24 14:23:30 EDT
Description of problem:

grep -r is behaving differently between distros. Not sure if a broken behavior has been fixed or bug introduced.

Version-Release number of selected component (if applicable):
grep-2.14-5.fc20.x86_64

How reproducible:
Always

Steps to Reproduce:

Execute the following from /tmp (THIS IS IMPORTANT)

1. grep -roe '^nfs.*--server' /root/anaconda-ks.cfg | grep -roe ^nfs

where anaconda-ks.cfg contains something like:

nfs --server=nfs-01.eng.brq.redhat.com --dir=/pub/fedora/linux/development-snapshot-20130924/20/x86_64/os/ --opts="nolock"

Actual results:
On RHEL 6 with grep-2.6.3-4.el6.x86_64 this yields just "nfs", while on Fedora 20 it yields empty string.

Expected results:
Same result in both versions.

Additional info:

Reading the man page I see -r is for recursion which is not needed in this case. Indeed removing -r from the command sequence gives correct results.


If you execute from /root on Fedora 20:
# grep -roe '^nfs.*--server' /root/anaconda-ks.cfg | grep -roe ^nfs
anaconda-ks.cfg:nfs
anaconda-ks.cfg:nfs

while on RHEL 6 from /root:
# grep -roe '^nfs.*--server' /root/anaconda-ks.cfg | grep -roe ^nfs
nfs


I think in the Fedora 20 version -r implies to recursively scan all files in the local directory regardless of input on stdout while in RHEL6 -r doesn't have an effect if a file/stdout is specified. Not sure which version is at fault.
Comment 1 Jaroslav Škarvada 2013-09-27 06:10:55 EDT
This seems to be bug in the RHEL-6 grep, that was fixed by the following upstream commit:
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=faf6ea13b3281a2004f5bfd1487708d1ba50a6c5

I think it is not worth backporting to RHEL-6. The current Fedora's prep behaviour is according to the manual page, thus closing as not a bug.

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