X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=findutils%2Fgrep.c;h=a2c07c52371513e07ad41408eb9140f9230edbb3;hb=bf181b9338152759fd56c8009e9a962a84808e7c;hp=dec365f05be675baf00d34a01e36db85dc91dba0;hpb=df5f6ba1159f8c1af500fa1b8eb9c9646e4de2a6;p=oweals%2Fbusybox.git diff --git a/findutils/grep.c b/findutils/grep.c index dec365f05..a2c07c523 100644 --- a/findutils/grep.c +++ b/findutils/grep.c @@ -31,21 +31,6 @@ extern int optind; /* in unistd.h */ extern int errno; /* for use with strerror() */ -static const char grep_usage[] = - "grep [-ihHnqvs] pattern [files...]\n" -#ifndef BB_FEATURE_TRIVIAL_HELP - "\nSearch for PATTERN in each FILE or standard input.\n\n" - "Options:\n" - "\t-H\tprefix output lines with filename where match was found\n" - "\t-h\tsuppress the prefixing filename on output\n" - "\t-i\tignore case distinctions\n" - "\t-n\tprint line number with output lines\n" - "\t-q\tbe quiet. Returns 0 if result was found, 1 otherwise\n" - "\t-v\tselect non-matching lines\n" - "\t-s\tsuppress file open/read error messages\n\n" -#endif - ; - /* options */ static int ignore_case = 0; static int print_filename = 0; @@ -146,8 +131,7 @@ extern int grep_main(int argc, char **argv) reflags = REG_NOSUB | REG_NEWLINE; if (ignore_case) reflags |= REG_ICASE; - if (bb_regcomp(®ex, argv[optind], reflags) != 0) - exit(1); + xregcomp(®ex, argv[optind], reflags); /* argv[(optind+1)..(argc-1)] should be names of file to grep through. If * there is more than one file to grep, we will print the filenames */ @@ -166,7 +150,7 @@ extern int grep_main(int argc, char **argv) file = fopen(cur_file, "r"); if (file == NULL) { if (!suppress_err_msgs) - fprintf(stderr, "grep: %s: %s\n", cur_file, strerror(errno)); + errorMsg("%s: %s\n", cur_file, strerror(errno)); } else { grep_file(file); fclose(file);