diff options
author | Charles Levert <charles_levert@gna.org> | 2005-06-21 05:18:44 +0000 |
---|---|---|
committer | Charles Levert <charles_levert@gna.org> | 2005-06-21 05:18:44 +0000 |
commit | 06574409465598d5e28d4f675a915830dd2c9d57 (patch) | |
tree | feabfc2568333895bf64549d3f8563f8987228ea | |
parent | 6efca6e7e7e973ac8941c8694cb956efc9764164 (diff) | |
download | grep-06574409465598d5e28d4f675a915830dd2c9d57.tar.gz |
* src/grep.c (main): Add a test to check if -o/--only-matching
and context lines are both specified and if so, set both context
specifications (before and after) to zero then print an explicit
warning to stderr explaining what was done and why (as opposed
to drastically aborting the process in error). Patch #3768.
Other code needs this zero setting to work correctly without
having to repeatedly test for this conflictual condition.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/grep.c | 8 |
2 files changed, 16 insertions, 0 deletions
@@ -5,6 +5,14 @@ right after a line boundary. This will be used later to fix --byte-offset's broken behavior. Patch #3769. + * src/grep.c (main): Add a test to check if -o/--only-matching + and context lines are both specified and if so, set both context + specifications (before and after) to zero then print an explicit + warning to stderr explaining what was done and why (as opposed + to drastically aborting the process in error). Patch #3768. + Other code needs this zero setting to work correctly without + having to repeatedly test for this conflictual condition. + 2005-06-20 Charles Levert <charles_levert@gna.org> * src/grep.c: Extensively document the SGR/EL-to-Right issue. @@ -1799,6 +1799,14 @@ main (int argc, char **argv) out_after = default_context; if (out_before < 0) out_before = default_context; + if (only_matching && (out_after > 0 || out_before > 0)) + { + fprintf(stderr, + _("%s: Any context line specification " + "is ignored with -o/--only-matching.\n"), + program_name); + out_after = out_before = 0; + } if (color_option) { |