diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-07-10 17:02:49 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-07-10 17:02:49 +0000 |
commit | 88ae4dea2b26c6ff7f11321fd139b96b7638da55 (patch) | |
tree | f7c2ffb086d2becdb2506909206a78aafed9a048 | |
parent | 3c2da0b399f449f80cde29a5ae4ba45a8414e3e7 (diff) |
grep should exit(2) on error, not exit(1) (1 means no matches found).
deraadt@ OK
-rw-r--r-- | usr.bin/grep/file.c | 14 | ||||
-rw-r--r-- | usr.bin/grep/grep.c | 8 | ||||
-rw-r--r-- | usr.bin/grep/util.c | 12 |
3 files changed, 17 insertions, 17 deletions
diff --git a/usr.bin/grep/file.c b/usr.bin/grep/file.c index 83f617583b9..eb6ff672976 100644 --- a/usr.bin/grep/file.c +++ b/usr.bin/grep/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.3 2003/06/22 22:38:50 deraadt Exp $ */ +/* $OpenBSD: file.c,v 1.4 2003/07/10 17:02:48 millert Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -68,9 +68,9 @@ gzfgetln(gzFile *f, size_t *len) gzerrstr = gzerror(f, &gzerr); if (gzerr == Z_ERRNO) - err(1, "%s", fname); + err(2, "%s", fname); else - errx(1, "%s: %s", fname, gzerrstr); + errx(2, "%s: %s", fname, gzerrstr); } if (c == '\n') break; @@ -162,7 +162,7 @@ grep_bin_file(file_t *f) #endif default: /* can't happen */ - errx(1, "invalid file type"); + errx(2, "invalid file type"); } } @@ -180,7 +180,7 @@ grep_tell(file_t *f) #endif default: /* can't happen */ - errx(1, "invalid file type"); + errx(2, "invalid file type"); } } @@ -198,7 +198,7 @@ grep_fgetln(file_t *f, size_t *l) #endif default: /* can't happen */ - errx(1, "invalid file type"); + errx(2, "invalid file type"); } } @@ -219,6 +219,6 @@ grep_close(file_t *f) #endif default: /* can't happen */ - errx(1, "invalid file type"); + errx(2, "invalid file type"); } } diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index 939a706491d..6cfa2f7f61c 100644 --- a/usr.bin/grep/grep.c +++ b/usr.bin/grep/grep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grep.c,v 1.19 2003/07/10 16:51:12 deraadt Exp $ */ +/* $OpenBSD: grep.c,v 1.20 2003/07/10 17:02:48 millert Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -190,7 +190,7 @@ read_patterns(char *fn) int nl; if ((f = fopen(fn, "r")) == NULL) - err(1, "%s", fn); + err(2, "%s", fn); nl = 0; while ((line = fgetln(f, &len)) != NULL) { if (*line == '\n') { @@ -205,7 +205,7 @@ read_patterns(char *fn) add_pattern(line, len); } if (ferror(f)) - err(1, "%s", fn); + err(2, "%s", fn); fclose(f); } @@ -426,7 +426,7 @@ main(int argc, char *argv[]) if ((c = regcomp(&r_pattern[i], pattern[i], cflags))) { regerror(c, &r_pattern[i], re_error, RE_ERROR_BUF); - errx(1, "%s", re_error); + errx(2, "%s", re_error); } } } diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c index 992079266dd..1e0591feb1a 100644 --- a/usr.bin/grep/util.c +++ b/usr.bin/grep/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.13 2003/07/06 19:16:45 avsm Exp $ */ +/* $OpenBSD: util.c,v 1.14 2003/07/10 17:02:48 millert Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -71,13 +71,13 @@ grep_tree(char **argv) fts_flags |= FTS_NOSTAT | FTS_NOCHDIR; if (!(fts = fts_open(argv, fts_flags, NULL))) - err(1, NULL); + err(2, NULL); while ((p = fts_read(fts)) != NULL) { switch (p->fts_info) { case FTS_DNR: break; case FTS_ERR: - errx(1, "%s: %s", p->fts_path, strerror(p->fts_errno)); + errx(2, "%s: %s", p->fts_path, strerror(p->fts_errno)); break; case FTS_DP: break; @@ -445,7 +445,7 @@ grep_malloc(size_t size) void *ptr; if ((ptr = malloc(size)) == NULL) - err(1, "malloc"); + err(2, "malloc"); return ptr; } @@ -453,7 +453,7 @@ void * grep_realloc(void *ptr, size_t size) { if ((ptr = realloc(ptr, size)) == NULL) - err(1, "realloc"); + err(2, "realloc"); return ptr; } @@ -463,7 +463,7 @@ grep_strdup(const char *str) unsigned char *ptr; if ((ptr = (unsigned char *)strdup(str)) == NULL) - err(1, "strdup"); + err(2, "strdup"); return ptr; } |