diff options
-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) { |