aboutsummaryrefslogtreecommitdiff
path: root/findutils
diff options
context:
space:
mode:
authorvodz <vodz@69ca8d6d-28ef-0310-b511-8ec308f3f277>2005-09-23 13:23:15 +0000
committervodz <vodz@69ca8d6d-28ef-0310-b511-8ec308f3f277>2005-09-23 13:23:15 +0000
commitc388ae879c15cdfc4dd83c9a7d63ec28c0f9f9a1 (patch)
tree7d0f12ea2040bfbde10bdfcdf65aa88f6708e8cb /findutils
parent3031c87b8df989cdb1404382fd17a2541602dcf2 (diff)
downloadbusybox-w32-c388ae879c15cdfc4dd83c9a7d63ec28c0f9f9a1.tar.gz
busybox-w32-c388ae879c15cdfc4dd83c9a7d63ec28c0f9f9a1.tar.bz2
busybox-w32-c388ae879c15cdfc4dd83c9a7d63ec28c0f9f9a1.zip
grep must have exit code >1 if input file not found. Small indent correcion also.
git-svn-id: svn://busybox.net/trunk/busybox@11591 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'findutils')
-rw-r--r--findutils/grep.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/findutils/grep.c b/findutils/grep.c
index a705df912..c3feb2018 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -260,6 +260,7 @@ extern int grep_main(int argc, char **argv)
260 int matched; 260 int matched;
261 unsigned long opt; 261 unsigned long opt;
262 llist_t *fopt = NULL; 262 llist_t *fopt = NULL;
263 int error_open_count = 0;
263 264
264 /* do normal option parsing */ 265 /* do normal option parsing */
265#ifdef CONFIG_FEATURE_GREP_CONTEXT 266#ifdef CONFIG_FEATURE_GREP_CONTEXT
@@ -375,6 +376,7 @@ extern int grep_main(int argc, char **argv)
375 if (file == NULL) { 376 if (file == NULL) {
376 if (!suppress_err_msgs) 377 if (!suppress_err_msgs)
377 bb_perror_msg("%s", cur_file); 378 bb_perror_msg("%s", cur_file);
379 error_open_count++;
378 } else { 380 } else {
379 matched += grep_file(file); 381 matched += grep_file(file);
380 if(matched < 0) { 382 if(matched < 0) {
@@ -382,9 +384,9 @@ extern int grep_main(int argc, char **argv)
382 * return success */ 384 * return success */
383 break; 385 break;
384 } 386 }
385 fclose(file); 387 fclose(file);
386 }
387 } 388 }
389 }
388 390
389#ifdef CONFIG_FEATURE_CLEAN_UP 391#ifdef CONFIG_FEATURE_CLEAN_UP
390 /* destroy all the elments in the pattern list */ 392 /* destroy all the elments in the pattern list */
@@ -396,5 +398,7 @@ extern int grep_main(int argc, char **argv)
396 } 398 }
397#endif 399#endif
398 400
401 if(error_open_count)
402 return 2;
399 return !matched; /* invert return value 0 = success, 1 = failed */ 403 return !matched; /* invert return value 0 = success, 1 = failed */
400} 404}