Bug 1256756
| Summary: | grep -r has been broken in RHEL 6.7 | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 6 | Reporter: | sivathanu <sivathanut> | ||||||
| Component: | grep | Assignee: | Jaroslav Škarvada <jskarvad> | ||||||
| Status: | CLOSED ERRATA | QA Contact: | Jan Kepler <jkejda> | ||||||
| Severity: | urgent | Docs Contact: | |||||||
| Priority: | urgent | ||||||||
| Version: | 6.7 | CC: | bnater, cww, fkrska, isenfeld, jdeenada, jesusislordcrom, jkejda, mkolaja, ovasik, pdwyer, salmy | ||||||
| Target Milestone: | rc | Keywords: | Patch, Regression, ZStream | ||||||
| Target Release: | --- | ||||||||
| Hardware: | x86_64 | ||||||||
| OS: | Linux | ||||||||
| Whiteboard: | |||||||||
| Fixed In Version: | grep-2.20-5.el6 | Doc Type: | If docs needed, set a value | ||||||
| Doc Text: | Story Points: | --- | |||||||
| Clone Of: | |||||||||
| : | 1367309 (view as bug list) | Environment: | |||||||
| Last Closed: | 2017-03-21 11:32:54 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: | |||||||
| Embargoed: | |||||||||
| Bug Depends On: | |||||||||
| Bug Blocks: | 1269194, 1355829, 1356054, 1367309 | ||||||||
| Attachments: |
|
||||||||
|
Description
sivathanu
2015-08-25 12:10:05 UTC
It works according to documentation: $ man grep -r, --recursive Read all files under each directory, recursively, following symbolic links only if they are on the command line. Note that if no file operand is given, grep searches the working directory. This is equivalent to the -d recurse option. Is there file containing the string 'grep-2.20-3.el6.x86_64' in your working directory? (In reply to Jaroslav Škarvada from comment #2) > It works according to documentation: > > $ man grep > -r, --recursive > Read all files under each directory, recursively, following symbolic links > only if they are on the command line. Note that if no file operand is given, > grep searches the working directory. This is equivalent to the -d recurse > option. > > Is there file containing the string 'grep-2.20-3.el6.x86_64' in your working > directory? Correct man text from RHEL-6.7 grep: -r, --recursive Read all files under each directory, recursively, following symbolic links only if they are on the command line. This is equivalent to the -d recurse option. It's missing the 'working directory' clarification, but the behaviour is according to the upstream documentation. We could update the manual page. I agree. When using grep only, the current behavior is correct. But using grep with result of "ls/rpm -qa" doesn't provide correct result. Can please execute the following command in RHEL 6.6 & 6.7 and elaborate the difference? rpm -qa | grep -r grep The result what i gathered from RHEL 6.6 & 6.7 are different. It made me to raise this bug. (In reply to Jaroslav Škarvada from comment #3) > (In reply to Jaroslav Škarvada from comment #2) > > It works according to documentation: > > > > $ man grep > > -r, --recursive > > Read all files under each directory, recursively, following symbolic links > > only if they are on the command line. Note that if no file operand is given, > > grep searches the working directory. This is equivalent to the -d recurse > > option. > > > > Is there file containing the string 'grep-2.20-3.el6.x86_64' in your working > > directory? > > Correct man text from RHEL-6.7 grep: > -r, --recursive > Read all files under each directory, recursively, following symbolic links > only if they are on the command line. This is equivalent to the -d recurse > option. > > It's missing the 'working directory' clarification, but the behaviour is > according to the upstream documentation. We could update the manual page. The current behaviour is logical and intended by upstream, from Paul Eggert commit:
This is a patch I've been meaning to put in for years.
When I added support for "grep -r", I forgot to have "grep -r PAT"
search the working directory by default, instead of searching
standard input (which makes no sense, even if stdin is a directory).
This is not an upward compatible change, since "grep -r PAT <file"
will no longer search standard input, but that's OK; nobody should
be using "grep -r" that way anyway.
I agree it's change in behaviour, but the previous behaviour wasn't correct. In case it's problem for you, please escalate this through the support channel, the old behaviour could be "forward ported", but it's something I would like to avoid if not necessary.
The problem: old behaviour: "grep -r PATTERN" - reads STD INPUT (-r is ignored) "grep -r PATTERN ." - recursively scans current directory for files containing the PATTERN New behaviour: "grep -r PATTERN" - recursively scans current directory for files containing the PATTERN "grep -r PATTERN ." - recursively scans current directory for files containing the PATTERN I think we need compatibility environment switch. Created attachment 1168411 [details]
Proposed fix
Scratch build for testing: http://people.redhat.com/jskarvad/rhbz1256756/ GREP_LEGACY_R=1 - means old behavior Created attachment 1168529 [details]
Proposed fix
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHBA-2017-0756.html |