diff options
author | 2012-12-29 01:32:44 +0000 | |
---|---|---|
committer | 2012-12-29 01:32:44 +0000 | |
commit | 20351096944346ffc3fb8d9fe1b200f956470cd2 (patch) | |
tree | 692cee0bc3c143a18f0dc97bcf873b73656aa95a /usr.bin/grep/grep.c | |
parent | Allow the relayd regression tests to run the relayd on a different (diff) | |
download | wireguard-openbsd-20351096944346ffc3fb8d9fe1b200f956470cd2.tar.xz wireguard-openbsd-20351096944346ffc3fb8d9fe1b200f956470cd2.zip |
Fix exit status when there is an error reading a file.
Reported by Jeramey Crawford, fix adapted from FreeBSD.
OK guenther@
Diffstat (limited to 'usr.bin/grep/grep.c')
-rw-r--r-- | usr.bin/grep/grep.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index eb467d7e352..c3ce3bb4a0d 100644 --- a/usr.bin/grep/grep.c +++ b/usr.bin/grep/grep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grep.c,v 1.44 2011/07/08 01:20:24 tedu Exp $ */ +/* $OpenBSD: grep.c,v 1.45 2012/12/29 01:32:44 millert Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -94,6 +94,7 @@ enum { /* Housekeeping */ int first; /* flag whether or not this is our first match */ int tail; /* lines left to print */ +int file_err; /* file reading error */ struct patfile { const char *pf_file; @@ -497,5 +498,5 @@ main(int argc, char *argv[]) for (c = 0; argc--; ++argv) c += procfile(*argv); - exit(!c); + exit(c ? (file_err ? (qflag ? 0 : 2) : 0) : (file_err ? 2 : 1)); } |