Bug #12785
closedgrep -h ignored with -r
100%
Description
Following the update of grep in #8858, grep -hr no longer works as expected.
A recursive grep (grep -r) will show matched filenames by default, but it's expected that -h will disable this. That's true of the old /usr/bin/grep and of GNU grep, but not of the old xpg4 grep and hence our current grep, which displays matching filenames if both -h and -r are given
Looking at the code, recursion sets outfn to 1. In the old grep, this was considered along with hflag at the output stage, allowing -h to override. This is no longer the case.
Updated by Peter Tribble almost 3 years ago
ReviewBoard link:
https://www.illumos.org/rb/r/2563/
Updated by Peter Tribble almost 3 years ago
Testing notes:
Manually tested that the new grep displays filenames (or not) as
expected depending on whether -h, -H, or neither, are given along with
-r.
Also updated the test suite to add tests for -h/-H and -r. The new
grep passes, as does GNU grep; the current grep fails the -hr test.
Updated by Electric Monk almost 3 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
git commit 4adc6f153a42519cb03b97bf215e1d4823300ebe
commit 4adc6f153a42519cb03b97bf215e1d4823300ebe Author: Peter Tribble <peter.tribble@gmail.com> Date: 2020-05-28T08:21:44.000Z 12785 grep -h ignored with -r Reviewed by: Yuri Pankov <yuripv@yuripv.net> Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk> Approved by: Joshua M. Clulow <josh@sysmgr.org>