Teach bsdgrep(1) to use the working directory if no -r directory is specified. This not only feels a little more sane than the default of grepping stdin, but it also matches newer GNU grep behavior.
PR: 216307
Differential D10108
bsdgrep(1): For -r, use the working directory if no directory is specified kevans on Mar 22 2017, 11:06 PM. Authored by Tags None Referenced Files
Subscribers
Details Teach bsdgrep(1) to use the working directory if no -r directory is specified. This not only feels a little more sane than the default of grepping stdin, but it also matches newer GNU grep behavior. PR: 216307 Check that there are no regressions in the kyua tests.
Diff Detail
Event TimelineThere are a very large number of changes, so older changes are hidden. Show Older Changes
Comment Actions Possibly just for convenience of passing the non-const argv. Some compilers produce (IMO, spurious) warnings passing non-const double pointers to const double pointer parameters. Or likely just to match the type of argv; FTS is very very old code (~1980). Comment Actions Yeah, I suppose I don't see the harm either way, now that I think about it. Changes to this implementation that might break this usage are going to have to be carefully considered anyways, yeah?
Comment Actions
Comment Actions Marking all of these as done, because grep_tree now uses the patch by @emaste, and I've simplified the weird if in grep.c. I'm still in favor of ripping out the grep_* layer to jemalloc(3) (and strdup), though, in a separate change.
Comment Actions I am imagining: fts = fts_open((argv[0] == NULL) ? __DECONST(char **, tdir): argv, fts_flags, NULL); if (fts == NULL) { ... Comment Actions
Comment Actions Also I had a small error; the proper cast should be __DECONST(char * const *, ...) to match the fts_open signature. No need to cast away more constness than necessary. Comment Actions And: sorry for all the nitpicking :-). We do really appreciate your patience and appreciation for getting the details right. LGTM modulo Ed's last nit about the DECONST type. Thanks! Comment Actions Whoops, sorry, I should have double-checked fts(3) after casting became necessary. =( Comment Actions Sorry, missed this comment: OTOH, you guys are putting up with all of the patches I'm flinging your way and helping me get things right, even for these small features that aren't strictly necessary and haven't been highly (or at all, from what I've found) requested. =)
Done!
Comment Actions
Comment Actions @ngie -- FYI, I've added two new test cases here under grep_freebsd_test rather than the standard grep_test since they are purely features added to bsdgrep(1) rather than tests of wonky behavior that GNU grep should be expected to handle
Comment Actions The linter/harbormaster seems to strongly dislike the test script, but this seems to generally be acceptable in, say, sed/tests/sed2_test.sh -- safe to ignore?
Comment Actions It's whining about an executable file being checked in without a shebang (which is generally bad, but in this case because they're tests and the shebang is added at build time), it's a harmless complaint. As I noted before though, doing chmod -x on the file will fix this issue (the executable bit is set at install time). Comment Actions Yeah, seemed kind of arbitrary, but I did it so that linter stays happy. =) How is this new version for compromise on testing? No timeout, skip if grep -r doesn't match anything in the test directory (it should match) and skip if the rgrep symlink isn't valid/usable.
Comment Actions
|