Bug 216307 - [patch] bsdgrep(1) : assume working directory for -r if no directory specified
Summary: [patch] bsdgrep(1) : assume working directory for -r if no directory specified
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Kyle Evans
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-01-20 03:30 UTC by Kyle Evans
Modified: 2017-08-29 21:23 UTC (History)
1 user (show)

See Also:
kevans: mfc-stable11+
kevans: mfc-stable10?
kevans: mfc-stable9-


Attachments
Proposed patch to use implied working directory for recursive searches (1.27 KB, patch)
2017-01-20 03:30 UTC, Kyle Evans
no flags Details | Diff
Proposed patch to use implied working directory for recursive searches (1.27 KB, patch)
2017-01-20 03:42 UTC, Kyle Evans
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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