Bug 216307

Summary: [patch] bsdgrep(1) : assume working directory for -r if no directory specified
Product: Base System Reporter: Kyle Evans <kevans>
Component: binAssignee: Kyle Evans <kevans>
Status: Closed FIXED    
Severity: Affects Only Me CC: emaste
Priority: --- Keywords: patch
Version: CURRENTFlags: kevans: mfc-stable11+
kevans: mfc-stable10?
kevans: mfc-stable9-
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Proposed patch to use implied working directory for recursive searches
none
Proposed patch to use implied working directory for recursive searches none

Description Kyle Evans freebsd_committer freebsd_triage 2017-01-20 03:30:43 UTC
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.
Comment 1 Kyle Evans freebsd_committer freebsd_triage 2017-01-20 03:42:13 UTC
Created attachment 179121 [details]
Proposed patch to use implied working directory for recursive searches

Noticed a parenthetical error upon my own initial re-review.
Comment 2 Ed Maste freebsd_committer freebsd_triage 2017-02-20 15:30:39 UTC
free(NULL) is well defined, so e.g.

	if(pwd != NULL)
		free(pwd);

ought to be just

	free(pwd);
Comment 3 commit-hook freebsd_committer freebsd_triage 2017-04-17 13:23:27 UTC
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
Comment 4 Ed Maste freebsd_committer freebsd_triage 2017-07-27 01:54:37 UTC
Reassign to Kyle (now a committer) for MFC tracking
Comment 5 commit-hook freebsd_committer freebsd_triage 2017-08-16 01:46:07 UTC
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