Created attachment 179120 [details] Proposed patch to use implied working directory for recursive searches Hi, Making an effort to migrate from newer versions of GNU grep to bsdgrep, cherry-picking this useful feature -- to assume the working directory is to be searched if no other directory is specified. Proposed patch is attached, presumably needs some work.
Created attachment 179121 [details] Proposed patch to use implied working directory for recursive searches Noticed a parenthetical error upon my own initial re-review.
free(NULL) is well defined, so e.g. if(pwd != NULL) free(pwd); ought to be just free(pwd);
A commit references this bug: Author: emaste Date: Mon Apr 17 13:22:40 UTC 2017 New revision: 317050 URL: https://svnweb.freebsd.org/changeset/base/317050 Log: bsdgrep: for -r, use the working directory if none specified This is more sensible than the previous behaviour of grepping stdin, and matches newer GNU grep behaviour. PR: 216307 Submitted by: Kyle Evans <kevans91 at ksu.edu> Reviewed by: cem, emaste, ngie Relnotes: Yes Differential Revision: https://reviews.freebsd.org/ Changes: head/usr.bin/grep/grep.c head/usr.bin/grep/tests/Makefile head/usr.bin/grep/tests/grep_freebsd_test.sh head/usr.bin/grep/util.c
Reassign to Kyle (now a committer) for MFC tracking
A commit references this bug: Author: kevans Date: Wed Aug 16 01:45:53 UTC 2017 New revision: 322564 URL: https://svnweb.freebsd.org/changeset/base/322564 Log: bsdgrep: Use implied working directory for -r if no directories are passed MFC r317050: bsdgrep: for -r, use the working directory if none specified This is more sensible than the previous behaviour of grepping stdin, and matches newer GNU grep behaviour. MFC r317300 (ngie): Only expect :grep_r_implied to pass with bsdgrep(1) The test fails with gnu grep from base and ports. MFC r319002 (ngie): :rgrep : use atf-check to check the exit code/save the output of grep -r instead of calling grep -r without it, and saving the output to a file This ensures that any errors thrown via grep -r are caught, not lost, and uses existing atf-sh idioms for saving files. PR: 216307 Approved by: emaste (mentor, blanket MFC) Relnotes: yes Changes: _U stable/11/ stable/11/usr.bin/grep/grep.c stable/11/usr.bin/grep/tests/Makefile stable/11/usr.bin/grep/tests/grep_freebsd_test.sh stable/11/usr.bin/grep/util.c