diff options
author | 2011-03-04 03:11:22 +0000 | |
---|---|---|
committer | 2011-03-04 03:11:22 +0000 | |
commit | 34fecf261ac0b7d9ad15f906b64cf859dbed945e (patch) | |
tree | d7b3ce076f0095177a7c55ed7803c140257c92db /usr.bin/grep/grep.c | |
parent | repair arguments passed to pfctl; PR 6142, ok beck (diff) | |
download | wireguard-openbsd-34fecf261ac0b7d9ad15f906b64cf859dbed945e.tar.xz wireguard-openbsd-34fecf261ac0b7d9ad15f906b64cf859dbed945e.zip |
add -H (opposite of -h) to always print name. ok deraadt millert
Diffstat (limited to 'usr.bin/grep/grep.c')
-rw-r--r-- | usr.bin/grep/grep.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index d34fd959750..e477cf97e3a 100644 --- a/usr.bin/grep/grep.c +++ b/usr.bin/grep/grep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grep.c,v 1.42 2010/07/02 22:18:03 tedu Exp $ */ +/* $OpenBSD: grep.c,v 1.43 2011/03/04 03:11:23 tedu Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -62,6 +62,7 @@ int Bflag; /* -B x: print x lines leading each match */ 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: always print filename header */ int Lflag; /* -L: only show names of files with no matches */ int Rflag; /* -R: recursively search directory trees */ #ifndef NOZ @@ -106,9 +107,9 @@ usage(void) { fprintf(stderr, #ifdef NOZ - "usage: %s [-abcEFGhIiLlnqRsUVvwx] [-A num] [-B num] [-C[num]]\n" + "usage: %s [-abcEFGHhIiLlnqRsUVvwx] [-A num] [-B num] [-C[num]]\n" #else - "usage: %s [-abcEFGhIiLlnqRsUVvwxZ] [-A num] [-B num] [-C[num]]\n" + "usage: %s [-abcEFGHhIiLlnqRsUVvwxZ] [-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); @@ -116,9 +117,9 @@ usage(void) } #ifdef NOZ -static char *optstr = "0123456789A:B:CEFGILRUVabce:f:hilnqrsuvwxy"; +static char *optstr = "0123456789A:B:CEFGHILRUVabce:f:hilnqrsuvwxy"; #else -static char *optstr = "0123456789A:B:CEFGILRUVZabce:f:hilnqrsuvwxy"; +static char *optstr = "0123456789A:B:CEFGHILRUVZabce:f:hilnqrsuvwxy"; #endif struct option long_options[] = @@ -134,6 +135,7 @@ struct option long_options[] = {"extended-regexp", no_argument, NULL, 'E'}, {"fixed-strings", no_argument, NULL, 'F'}, {"basic-regexp", no_argument, NULL, 'G'}, + {"with-filename", no_argument, NULL, 'H'}, {"binary", no_argument, NULL, 'U'}, {"version", no_argument, NULL, 'V'}, {"text", no_argument, NULL, 'a'}, @@ -315,6 +317,9 @@ main(int argc, char *argv[]) Eflag = Fflag = 0; Gflag++; break; + case 'H': + Hflag++; + break; case 'I': binbehave = BIN_FILE_SKIP; break; @@ -476,7 +481,7 @@ main(int argc, char *argv[]) if (lbflag) setlinebuf(stdout); - if ((argc == 0 || argc == 1) && !Rflag) + if ((argc == 0 || argc == 1) && !Rflag && !Hflag) hflag = 1; if (argc == 0) |