summaryrefslogtreecommitdiffstats
path: root/usr.bin/grep
diff options
context:
space:
mode:
authorgabor <gabor@FreeBSD.org>2011-11-28 20:00:31 +0000
committergabor <gabor@FreeBSD.org>2011-11-28 20:00:31 +0000
commit7b8d844d3a215213a277d9a84b016fda9fcdc3ea (patch)
tree7d007e8d387185a59deb264a48024f9ea6285052 /usr.bin/grep
parent13174669a049b9fc6fd246482f95de6970bdeabe (diff)
downloadFreeBSD-src-7b8d844d3a215213a277d9a84b016fda9fcdc3ea.zip
FreeBSD-src-7b8d844d3a215213a277d9a84b016fda9fcdc3ea.tar.gz
- Fix behavior of --null to match GNU grep
PR: bin/162906 Submitted by: Jan Beich <jbeich@tormail.net> MFC after: 3 days
Diffstat (limited to 'usr.bin/grep')
-rw-r--r--usr.bin/grep/util.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c
index 785961b..447e8c5 100644
--- a/usr.bin/grep/util.c
+++ b/usr.bin/grep/util.c
@@ -246,9 +246,9 @@ procfile(const char *fn)
printf("%u\n", c);
}
if (lflag && !qflag && c != 0)
- printf("%s\n", fn);
+ printf("%s%c", fn, nullflag ? 0 : '\n');
if (Lflag && !qflag && c == 0)
- printf("%s\n", fn);
+ printf("%s%c", fn, nullflag ? 0 : '\n');
if (c && !cflag && !lflag && !Lflag &&
binbehave == BINFILE_BIN && f->binary && !qflag)
printf(getstr(8), fn);
@@ -440,13 +440,13 @@ printline(struct str *line, int sep, regmatch_t *matches, int m)
int i, n = 0;
if (!hflag) {
- if (nullflag == 0)
+ if (!nullflag) {
fputs(line->file, stdout);
- else {
+ ++n;
+ } else {
printf("%s", line->file);
putchar(0);
}
- ++n;
}
if (nflag) {
if (n > 0)
OpenPOWER on IntegriCloud