aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author"Vladimir N. Oleynik" <dzo@simtreas.ru>2005-09-23 13:23:15 +0000
committer"Vladimir N. Oleynik" <dzo@simtreas.ru>2005-09-23 13:23:15 +0000
commitcf40d8175b230e01eef7a1a0d1c7cb8d1409dab5 (patch)
tree7d0f12ea2040bfbde10bdfcdf65aa88f6708e8cb
parentb628409b1e18aa6cdcf485077a3a64276e817db9 (diff)
downloadbusybox-w32-cf40d8175b230e01eef7a1a0d1c7cb8d1409dab5.tar.gz
busybox-w32-cf40d8175b230e01eef7a1a0d1c7cb8d1409dab5.tar.bz2
busybox-w32-cf40d8175b230e01eef7a1a0d1c7cb8d1409dab5.zip
grep must have exit code >1 if input file not found. Small indent correcion also.
-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}