summaryrefslogtreecommitdiffstats
path: root/usr.bin/grep
diff options
context:
space:
mode:
authorgabor <gabor@FreeBSD.org>2011-12-07 12:25:28 +0000
committergabor <gabor@FreeBSD.org>2011-12-07 12:25:28 +0000
commitecc4a991f39a9b982c50d896d09676012b5d60a2 (patch)
tree66129dad0d79d406d6afa067e0d889b5d81d5ab2 /usr.bin/grep
parente6144483bb2ddda3b5fe8480a1d3771c140b30ea (diff)
downloadFreeBSD-src-ecc4a991f39a9b982c50d896d09676012b5d60a2.zip
FreeBSD-src-ecc4a991f39a9b982c50d896d09676012b5d60a2.tar.gz
- Match GNU behavior of exit code
- Rename variable that has a different meaning now PR: bin/162930 Submitted by: Jan Beich <jbeich@tormail.net> MFC after: 1 week
Diffstat (limited to 'usr.bin/grep')
-rw-r--r--usr.bin/grep/grep.c4
-rw-r--r--usr.bin/grep/grep.h2
-rw-r--r--usr.bin/grep/util.c5
3 files changed, 5 insertions, 6 deletions
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c
index 288df90..4eb4727 100644
--- a/usr.bin/grep/grep.c
+++ b/usr.bin/grep/grep.c
@@ -148,7 +148,7 @@ static inline const char *init_color(const char *);
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));
}
diff --git a/usr.bin/grep/grep.h b/usr.bin/grep/grep.h
index 47d4ab9..2a8f425 100644
--- a/usr.bin/grep/grep.h
+++ b/usr.bin/grep/grep.h
@@ -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;
diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c
index 75ed107..4fb1240 100644
--- a/usr.bin/grep/util.c
+++ b/usr.bin/grep/util.c
@@ -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);
}
OpenPOWER on IntegriCloud