From owner-svn-src-all@FreeBSD.ORG Thu Dec 1 13:53:34 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7415C1065675; Thu, 1 Dec 2011 13:53:34 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 635838FC14; Thu, 1 Dec 2011 13:53:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pB1DrYlm047808; Thu, 1 Dec 2011 13:53:34 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB1DrYQL047806; Thu, 1 Dec 2011 13:53:34 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201112011353.pB1DrYQL047806@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 1 Dec 2011 13:53:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org X-SVN-Group: releng MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228180 - releng/9.0/usr.bin/grep X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Dec 2011 13:53:34 -0000 Author: gabor Date: Thu Dec 1 13:53:33 2011 New Revision: 228180 URL: http://svn.freebsd.org/changeset/base/228180 Log: MFC 228093 - Fix behavior of --null to match GNU grep MFC 228097 - Call warnx() instead of errx() if a directory is not readable when using a recursive search. This is the expected behavior instead of aborting. Approved by: re (kib) Modified: releng/9.0/usr.bin/grep/util.c Directory Properties: releng/9.0/usr.bin/grep/ (props changed) Modified: releng/9.0/usr.bin/grep/util.c ============================================================================== --- releng/9.0/usr.bin/grep/util.c Thu Dec 1 13:53:08 2011 (r228179) +++ releng/9.0/usr.bin/grep/util.c Thu Dec 1 13:53:33 2011 (r228180) @@ -130,7 +130,9 @@ grep_tree(char **argv) case FTS_DNR: /* FALLTHROUGH */ case FTS_ERR: - errx(2, "%s: %s", p->fts_path, strerror(p->fts_errno)); + notfound = true; + if(!sflag) + warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); break; case FTS_D: /* FALLTHROUGH */ @@ -246,9 +248,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 +442,13 @@ printline(struct str *line, int sep, reg 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)