From: John Marino Date: Tue, 8 May 2012 17:02:03 +0000 (+0200) Subject: grep: remove local option --only-files permanently X-Git-Tag: v3.2.0~994 X-Git-Url: https://gitweb.dragonflybsd.org/~nant/dragonfly.git/commitdiff_plain/0ccaf658083d02919184683e49a33e9088ccb047 grep: remove local option --only-files permanently The grep option --only-files exists only on DragonFly. It was added in late 2005 by Simon Schubert as a quick and dirty way to search object directories using grep rather than a complex find command. The issue was that some directory symlinks were created that produced recursive loops. There wasn't a lot of support for the suggestion, but when the code was altered to allow non-directory symlinks to be followed by the --only-files option, the main objection was addressed. The problem is that this modification is making it difficult to maintain grep. The code that it touches changes frequently, and its unmergable with grep 2.12. The burden of maintaining this option is too much considering it may only have a single user. Discussed with: Dillon For the purposes of merging grep 2.12, the hammer bug fix is also being removed since it doesn't merge cleanly, but it will be restored after the merge. --- diff --git a/contrib/grep/doc/grep.texi b/contrib/grep/doc/grep.texi index fe40dd26a5..7c80f8c21e 100644 --- a/contrib/grep/doc/grep.texi +++ b/contrib/grep/doc/grep.texi @@ -650,15 +650,6 @@ For each directory mentioned on the command line, read and process all files in that directory, recursively. This is the same as the @samp{--directories=recurse} option. -@item -O -@itemx --only-files -@opindex -O -@opindex --only-files -@cindex ignoring special files -@cindex ignoring symlinked directories -Ignore all special files, except for symlinks. -When recursing into directories, ignore symlinked directories as well. - @end table @node Other Options diff --git a/contrib/grep/src/main.c b/contrib/grep/src/main.c index 043a6b988c..4e01a17769 100644 --- a/contrib/grep/src/main.c +++ b/contrib/grep/src/main.c @@ -57,7 +57,7 @@ #define AUTHORS \ proper_name ("Mike Haertel"), \ - _("others, see\n") + _("others, see ") struct stats { @@ -272,7 +272,7 @@ static struct exclude *included_patterns; static struct exclude *excluded_directory_patterns; /* Short options. */ static char const short_options[] = -"0123456789A:B:C:D:EFGHIOPTUVX:abcd:e:f:hiKLlm:noqRrsuvwxyZz"; +"0123456789A:B:C:D:EFGHIPTUVX:abcd:e:f:hiKLlm:noqRrsuvwxyZz"; /* Non-boolean long options that have no corresponding short equivalents. */ enum @@ -331,7 +331,6 @@ static struct option const long_options[] = {"no-messages", no_argument, NULL, 's'}, {"null", no_argument, NULL, 'Z'}, {"null-data", no_argument, NULL, 'z'}, - {"only-files", no_argument, NULL, 'O'}, {"only-matching", no_argument, NULL, 'o'}, {"quiet", no_argument, NULL, 'q'}, {"recursive", no_argument, NULL, 'r'}, @@ -379,9 +378,6 @@ ARGMATCH_VERIFY (directories_args, directories_types); static enum directories_type directories = READ_DIRECTORIES; -/* How to handle dir/device/links */ -static int only_files; - /* How to handle devices. */ static enum { @@ -1097,10 +1093,7 @@ grep (int fd, char const *file, struct stats *stats) if (! fillbuf (save, stats)) { if (! is_EISDIR (errno, file)) - { - if (errno != EINVAL) - suppressible_error (filename, errno); - } + suppressible_error (filename, errno); return 0; } @@ -1212,20 +1205,6 @@ grepfile (char const *file, struct stats *stats) suppressible_error (file, errno); return 1; } - if (only_files) - { - if (S_ISDIR (stats->stat.st_mode)) - { - if (directories != RECURSE_DIRECTORIES) - return 1; - if (lstat(file, &stats->stat) != 0) - return 1; - if (!S_ISDIR (stats->stat.st_mode)) - return 1; - } - else if (!S_ISREG (stats->stat.st_mode)) - return 1; - } if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode)) return 1; if (devices == SKIP_DEVICES && (S_ISCHR (stats->stat.st_mode) @@ -1242,13 +1221,11 @@ grepfile (char const *file, struct stats *stats) if (is_EISDIR (e, file) && directories == RECURSE_DIRECTORIES) { -#if 0 /* DISABLED by only-files local modification option */ if (stat (file, &stats->stat) != 0) { error (0, errno, "%s", file); return 1; } -#endif return grepdir (file, stats); } @@ -1465,18 +1442,15 @@ Output control:\n\ printf (_("\ --include=FILE_PATTERN search only files that match FILE_PATTERN\n\ --exclude=FILE_PATTERN skip files and directories matching FILE_PATTERN\n\ - --exclude-from=FILE skip files matching any file pattern from FILE\n\ - --exclude-dir=PATTERN directories that match PATTERN will be skipped.\n\ + --exclude-from=FILE skip files matching any file pattern from FILE\n\ + --exclude-dir=PATTERN directories that match PATTERN will be skipped.\n\ ")); printf (_("\ - -O, --only-files Ignore special files, except symlinks.\n\ - When recursing directories, ignore symlinked\n\ - directories as well.\n\ -L, --files-without-match print only names of FILEs containing no match\n\ - -l, --files-with-matches print only names of FILEs containing matches\n\ - -c, --count print only a count of matching lines per FILE\n\ - -T, --initial-tab make tabs line up (if needed)\n\ - -Z, --null print 0 byte after FILE name\n")); + -l, --files-with-matches print only names of FILEs containing matches\n\ + -c, --count print only a count of matching lines per FILE\n\ + -T, --initial-tab make tabs line up (if needed)\n\ + -Z, --null print 0 byte after FILE name\n")); printf (_("\ \n\ Context control:\n\ @@ -1873,10 +1847,6 @@ main (int argc, char **argv) binary_files = WITHOUT_MATCH_BINARY_FILES; break; - case 'O': - only_files = 1; - break; - case 'T': align_tabs = 1; break;