aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-05-17 02:54:32 -0500
committerRob Landley <rob@landley.net>2019-05-17 02:54:32 -0500
commita39eab3fc7da89f2ee743dd116be632189f32c80 (patch)
treebbd3fa9e4dcdeb49c5d9032eb462ac2fbfe66267 /toys/posix
parentada1b3ab1edab71a185fba6c2ee98d1985933be5 (diff)
downloadtoybox-a39eab3fc7da89f2ee743dd116be632189f32c80.tar.gz
Fix a missing else, and an inverted test hidden by the missing else.
Add test to show failure case.
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/grep.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/toys/posix/grep.c b/toys/posix/grep.c
index c88d4c65..5afe38ca 100644
--- a/toys/posix/grep.c
+++ b/toys/posix/grep.c
@@ -173,14 +173,13 @@ static void do_grep(int fd, char *name)
for (seek = TT.e; seek; seek = seek->next) {
if (FLAG(x)) {
- if ((FLAG(i) ? strcasecmp : strcmp)(seek->arg, line)) s = line;
+ if (!(FLAG(i) ? strcasecmp : strcmp)(seek->arg, line)) s = line;
} else if (!*seek->arg) {
seek = &fseek;
fseek.arg = s = line;
- break;
- }
- if (FLAG(i)) s = strcasestr(line, seek->arg);
+ } else if (FLAG(i)) s = strcasestr(line, seek->arg);
else s = strstr(line, seek->arg);
+
if (s) break;
}