From owner-svn-src-all@FreeBSD.ORG Wed Dec 7 12:25:29 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 39FCA106566B; Wed, 7 Dec 2011 12:25:29 +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 105CC8FC0C; Wed, 7 Dec 2011 12:25:29 +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 pB7CPSxt039284; Wed, 7 Dec 2011 12:25:28 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB7CPS1D039280; Wed, 7 Dec 2011 12:25:28 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201112071225.pB7CPS1D039280@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 7 Dec 2011 12:25:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228319 - head/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: Wed, 07 Dec 2011 12:25:29 -0000 Author: gabor Date: Wed Dec 7 12:25:28 2011 New Revision: 228319 URL: http://svn.freebsd.org/changeset/base/228319 Log: - Match GNU behavior of exit code - Rename variable that has a different meaning now PR: bin/162930 Submitted by: Jan Beich MFC after: 1 week Modified: head/usr.bin/grep/grep.c head/usr.bin/grep/grep.h head/usr.bin/grep/util.c Modified: head/usr.bin/grep/grep.c ============================================================================== --- head/usr.bin/grep/grep.c Wed Dec 7 11:06:18 2011 (r228318) +++ head/usr.bin/grep/grep.c Wed Dec 7 12:25:28 2011 (r228319) @@ -148,7 +148,7 @@ static inline const char *init_color(con bool first = true; /* flag whether we are processing the first match */ bool prev; /* flag whether or not the previous line matched */ int tail; /* lines left to print */ -bool notfound; /* file not found */ +bool file_err; /* file reading error */ /* * Prints usage information and returns 2. @@ -728,5 +728,5 @@ main(int argc, char *argv[]) /* Find out the correct return value according to the results and the command line option. */ - exit(c ? (notfound ? (qflag ? 0 : 2) : 0) : (notfound ? 2 : 1)); + exit(c ? (file_err ? (qflag ? 0 : 2) : 0) : (file_err ? 2 : 1)); } Modified: head/usr.bin/grep/grep.h ============================================================================== --- head/usr.bin/grep/grep.h Wed Dec 7 11:06:18 2011 (r228318) +++ head/usr.bin/grep/grep.h Wed Dec 7 12:25:28 2011 (r228319) @@ -119,7 +119,7 @@ extern char *label; extern const char *color; extern int binbehave, devbehave, dirbehave, filebehave, grepbehave, linkbehave; -extern bool first, matchall, notfound, prev; +extern bool file_err, first, matchall, prev; extern int tail; extern unsigned int dpatterns, fpatterns, patterns; extern struct pat *pattern; Modified: head/usr.bin/grep/util.c ============================================================================== --- head/usr.bin/grep/util.c Wed Dec 7 11:06:18 2011 (r228318) +++ head/usr.bin/grep/util.c Wed Dec 7 12:25:28 2011 (r228319) @@ -130,7 +130,7 @@ grep_tree(char **argv) case FTS_DNR: /* FALLTHROUGH */ case FTS_ERR: - notfound = true; + file_err = true; if(!sflag) warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); break; @@ -195,10 +195,9 @@ procfile(const char *fn) f = grep_open(fn); } if (f == NULL) { + file_err = true; if (!sflag) warn("%s", fn); - if (errno == ENOENT) - notfound = true; return (0); }