There are 3 sets of options in the greposphere. Some are defined by
posix. Some are extensions defined by gnu. And then there's a few others
that show up in our grep.
This diff removes some of the entries in the last set. For the most part,
our grep tries to be compatible with the defacto gnu standard for grep,
but there's no need to blaze our own trail.
These options relate to symlink handling, for which gnu grep has no
equivalent, and for which I'd say the answer is, if you care, you use
find. That's what find is for.
Index: grep.1
===================================================================
RCS file: /home/tedu/cvs/src/usr.bin/grep/grep.1,v
retrieving revision 1.36
diff -u -r1.36 grep.1
--- grep.1 8 Feb 2009 17:15:10 -0000 1.36
+++ grep.1 2 Apr 2010 02:14:18 -0000
@@ -38,7 +38,7 @@
.Sh SYNOPSIS
.Nm grep
.Bk -words
-.Op Fl abcEFGHhIiLlnoPqRSsUVvwxZ
+.Op Fl abcEFGhIiLlnqRsUVvwxZ
.Op Fl A Ar num
.Op Fl B Ar num
.Op Fl C Ns Op Ar num
@@ -183,12 +183,6 @@
.Nm grep
to behave as traditional
.Nm grep ) .
-.It Fl H
-If
-.Fl R
-is specified, follow symbolic links only if they were explicitly listed
-on the command line.
-The default is not to follow symbolic links.
.It Fl h
Never print filename headers
.Pq i.e. filenames
@@ -229,13 +223,6 @@
.Fl q
is
specified.
-.It Fl o
-Always print filename headers with output lines.
-.It Fl P
-If
-.Fl R
-is specified, no symbolic links are followed.
-This is the default.
.It Fl q
Quiet mode:
suppress normal output.
@@ -244,11 +231,6 @@
making searches potentially less expensive.
.It Fl R
Recursively search subdirectories listed.
-.It Fl S
-If
-.Fl R
-is specified, all symbolic links are followed.
-The default is not to follow symbolic links.
.It Fl s
Silent mode.
Nonexistent and unreadable files are ignored
@@ -367,7 +349,7 @@
specification.
.Pp
The flags
-.Op Fl AaBbCGHhILoPRSUVwZ
+.Op Fl AaBbCGhILRUVwZ
are extensions to that specification, and the behaviour of the
.Fl f
flag when used with an empty pattern file is left undefined.
Index: grep.c
===================================================================
RCS file: /home/tedu/cvs/src/usr.bin/grep/grep.c,v
retrieving revision 1.39
diff -u -r1.39 grep.c
--- grep.c 2 Sep 2007 15:19:32 -0000 1.39
+++ grep.c 2 Apr 2010 02:18:11 -0000
@@ -62,11 +62,8 @@
int Eflag; /* -E: interpret pattern as extended regexp */
int Fflag; /* -F: interpret pattern as list of fixed strings */
int Gflag; /* -G: interpret pattern as basic regexp */
-int Hflag; /* -H: if -R, follow explicitly listed symlinks */
int Lflag; /* -L: only show names of files with no matches */
-int Pflag; /* -P: if -R, no symlinks are followed */
int Rflag; /* -R: recursively search directory trees */
-int Sflag; /* -S: if -R, follow all symlinks */
#ifndef NOZ
int Zflag; /* -Z: decompress input before processing */
#endif
@@ -76,7 +73,6 @@
int iflag; /* -i: ignore case */
int lflag; /* -l: only show names of files with matches */
int nflag; /* -n: show line numbers in front of matching lines */
-int oflag; /* -o: always print file name */
int qflag; /* -q: quiet mode (don't output anything) */
int sflag; /* -s: silent mode (ignore errors) */
int vflag; /* -v: only show non-matching lines */
@@ -110,9 +106,9 @@
{
fprintf(stderr,
#ifdef NOZ
- "usage: %s [-abcEFGHhIiLlnoPqRSsUVvwx] [-A num] [-B num]
[-C[num]]\n"
+ "usage: %s [-abcEFGhIiLlnqRsUVvwx] [-A num] [-B num] [-C[num]]\n"
#else
- "usage: %s [-abcEFGHhIiLlnoPqRSsUVvwxZ] [-A num] [-B num]
[-C[num]]\n"
+ "usage: %s [-abcEFGhIiLlnqRsUVvwxZ] [-A num] [-B num] [-C[num]]\n"
#endif
"\t[-e pattern] [-f file] [--binary-files=value]
[--context[=num]]\n"
"\t[--line-buffered] [pattern] [file ...]\n", __progname);
@@ -120,9 +116,9 @@
}
#ifdef NOZ
-static char *optstr = "0123456789A:B:CEFGHILPSRUVabce:f:hilnoqrsuvwxy";
+static char *optstr = "0123456789A:B:CEFGILRUVabce:f:hilnqrsuvwxy";
#else
-static char *optstr = "0123456789A:B:CEFGHILPSRUVZabce:f:hilnoqrsuvwxy";
+static char *optstr = "0123456789A:B:CEFGILRUVZabce:f:hilnqrsuvwxy";
#endif
struct option long_options[] =
@@ -317,9 +313,6 @@
Eflag = Fflag = 0;
Gflag++;
break;
- case 'H':
- Hflag++;
- break;
case 'I':
binbehave = BIN_FILE_SKIP;
break;
@@ -327,16 +320,9 @@
lflag = 0;
Lflag = qflag = 1;
break;
- case 'P':
- Pflag++;
- break;
- case 'S':
- Sflag++;
- break;
case 'R':
case 'r':
Rflag++;
- oflag++;
break;
case 'U':
binbehave = BIN_FILE_BIN;
@@ -370,7 +356,6 @@
needpattern = 0;
break;
case 'h':
- oflag = 0;
hflag = 1;
break;
case 'i':
@@ -385,10 +370,6 @@
case 'n':
nflag = 1;
break;
- case 'o':
- hflag = 0;
- oflag = 1;
- break;
case 'q':
qflag = 1;
break;
@@ -472,7 +453,7 @@
if (lbflag)
setlinebuf(stdout);
- if ((argc == 0 || argc == 1) && !oflag)
+ if ((argc == 0 || argc == 1))
hflag = 1;
if (argc == 0)
Index: grep.h
===================================================================
RCS file: /home/tedu/cvs/src/usr.bin/grep/grep.h,v
retrieving revision 1.14
diff -u -r1.14 grep.h
--- grep.h 2 Sep 2007 15:19:32 -0000 1.14
+++ grep.h 2 Apr 2010 02:04:19 -0000
@@ -63,8 +63,8 @@
extern int cflags, eflags;
/* Command line flags */
-extern int Aflag, Bflag, Eflag, Fflag, Gflag, Hflag, Lflag, Pflag,
- Sflag, Rflag, Zflag,
+extern int Aflag, Bflag, Eflag, Fflag, Gflag, Lflag,
+ Rflag, Zflag,
bflag, cflag, hflag, iflag, lflag, nflag, qflag, sflag,
vflag, wflag, xflag;
extern int binbehave;
Index: util.c
===================================================================
RCS file: /home/tedu/cvs/src/usr.bin/grep/util.c,v
retrieving revision 1.36
diff -u -r1.36 util.c
--- util.c 2 Oct 2007 17:59:18 -0000 1.36
+++ util.c 2 Apr 2010 02:04:02 -0000
@@ -61,13 +61,6 @@
c = fts_flags = 0;
- if (Hflag)
- fts_flags = FTS_COMFOLLOW;
- if (Pflag)
- fts_flags = FTS_PHYSICAL;
- if (Sflag)
- fts_flags = FTS_LOGICAL;
-
fts_flags |= FTS_NOSTAT | FTS_NOCHDIR;
if (!(fts = fts_open(argv, fts_flags, NULL)))