summaryrefslogtreecommitdiffstats
path: root/toolbox
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2017-04-17 13:22:39 +0000
committerMichael Bestas <mkbestas@lineageos.org>2019-12-11 23:51:45 +0200
commit8abb3258d34f02affc444de3d71d83ba2d0d275d (patch)
tree07af2079e3b44c3ec3e2bb6574f611bd1f1ab15b /toolbox
parentbd4142eab8b3cead0c25a2e660b4b048d1315d3c (diff)
downloadsystem_core-8abb3258d34f02affc444de3d71d83ba2d0d275d.tar.gz
system_core-8abb3258d34f02affc444de3d71d83ba2d0d275d.tar.bz2
system_core-8abb3258d34f02affc444de3d71d83ba2d0d275d.zip
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/ Change-Id: I9dc42c4105c35c42c6b195c880c70f4398852886
Diffstat (limited to 'toolbox')
-rw-r--r--toolbox/upstream-netbsd/usr.bin/grep/grep.c2
-rw-r--r--toolbox/upstream-netbsd/usr.bin/grep/util.c5
2 files changed, 5 insertions, 2 deletions
diff --git a/toolbox/upstream-netbsd/usr.bin/grep/grep.c b/toolbox/upstream-netbsd/usr.bin/grep/grep.c
index bad2a7398..4990dc18d 100644
--- a/toolbox/upstream-netbsd/usr.bin/grep/grep.c
+++ b/toolbox/upstream-netbsd/usr.bin/grep/grep.c
@@ -700,7 +700,7 @@ main(int argc, char *argv[])
if ((aargc == 0 || aargc == 1) && !Hflag)
hflag = true;
- if (aargc == 0)
+ if (aargc == 0 && dirbehave != DIR_RECURSE)
exit(!procfile("-"));
if (dirbehave == DIR_RECURSE)
diff --git a/toolbox/upstream-netbsd/usr.bin/grep/util.c b/toolbox/upstream-netbsd/usr.bin/grep/util.c
index a3c9e4c30..7b3d80cd4 100644
--- a/toolbox/upstream-netbsd/usr.bin/grep/util.c
+++ b/toolbox/upstream-netbsd/usr.bin/grep/util.c
@@ -117,6 +117,7 @@ grep_tree(char **argv)
char *d, *dir = NULL;
int c, fts_flags;
bool ok;
+ const char *wd[] = { ".", NULL };
c = fts_flags = 0;
@@ -134,7 +135,9 @@ grep_tree(char **argv)
fts_flags |= FTS_NOSTAT | FTS_NOCHDIR;
- if (!(fts = fts_open(argv, fts_flags, NULL)))
+ fts = fts_open((argv[0] == NULL) ?
+ ((char * const *)(uintptr_t)(const void *)wd) : argv, fts_flags, NULL);
+ if (fts == NULL)
err(2, "fts_open");
while ((p = fts_read(fts)) != NULL) {
switch (p->fts_info) {