Mercurial > hg > toybox
changeset 1023:97383e221a4a
Fix bug where exit code was only correct for -q.
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 21 Aug 2013 05:38:53 -0500 |
parents | 71f64e2f24a9 |
children | 63b8e54d2c6f |
files | toys/posix/grep.c |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/toys/posix/grep.c Wed Aug 21 03:03:47 2013 -0500 +++ b/toys/posix/grep.c Wed Aug 21 05:38:53 2013 -0500 @@ -84,7 +84,11 @@ char *s = 0; for (seek = TT.e; seek; seek = seek->next) { - if (!*seek->arg) { + if (toys.optflags & FLAG_x) { + int i = (toys.optflags & FLAG_i); + + if ((i ? strcasecmp : strcmp)(seek->arg, line)) s = line; + } else if (!*seek->arg) { seek = &fseek; fseek.arg = s = line; break; @@ -127,10 +131,8 @@ } else if (rc) break; mmatch++; - if (toys.optflags & FLAG_q) { - toys.exitval = 0; - xexit(); - } + toys.exitval = 0; + if (toys.optflags & FLAG_q) xexit(); if (toys.optflags & FLAG_l) { printf("%s\n", name); free(line);