FreeBSD Bugzilla – Attachment 179120 Details for
Bug 216307
[patch] bsdgrep(1) : assume working directory for -r if no directory specified
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch to use implied working directory for recursive searches
grep.patch (text/plain), 1.27 KB, created by
Kyle Evans
on 2017-01-20 03:30:43 UTC
(
hide
)
Description:
Proposed patch to use implied working directory for recursive searches
Filename:
MIME Type:
Creator:
Kyle Evans
Created:
2017-01-20 03:30:43 UTC
Size:
1.27 KB
patch
obsolete
>diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c >index ecb176df42b..507f0b48113 100644 >--- a/usr.bin/grep/grep.c >+++ b/usr.bin/grep/grep.c >@@ -725,7 +725,7 @@ main(int argc, char *argv[]) > if ((aargc == 0 || aargc == 1) && !Hflag) > hflag = true; > >- if (aargc == 0) >+ if (aargc == 0 && (dirbehave != DIR_RECURSE || patterns == 0)) > exit(!procfile("-")); > > if (dirbehave == DIR_RECURSE) >diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c >index 5583c803abc..fa1a967463f 100644 >--- a/usr.bin/grep/util.c >+++ b/usr.bin/grep/util.c >@@ -111,6 +111,7 @@ grep_tree(char **argv) > FTSENT *p; > int c, fts_flags; > bool ok; >+ char **tdir = NULL, *pwd = NULL; > > c = fts_flags = 0; > >@@ -128,7 +129,14 @@ grep_tree(char **argv) > > fts_flags |= FTS_NOSTAT | FTS_NOCHDIR; > >- if (!(fts = fts_open(argv, fts_flags, NULL))) >+ if(argv[0] == NULL) { >+ tdir = grep_calloc(2, sizeof(char *)); >+ if((pwd = getcwd(NULL, 0)) == NULL) >+ err(2, "getcwd"); >+ tdir[0] = pwd; >+ } >+ >+ if (!(fts = fts_open((tdir != NULL ? tdir : argv), fts_flags, NULL))) > err(2, "fts_open"); > while ((p = fts_read(fts)) != NULL) { > switch (p->fts_info) { >@@ -165,6 +173,13 @@ grep_tree(char **argv) > } > > fts_close(fts); >+ >+ if(pwd != NULL) >+ free(pwd); >+ >+ if(tdir != NULL) >+ free(tdir); >+ > return (c); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 216307
:
179120
|
179121