summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--src/grep.c8
2 files changed, 16 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c3ced5d2..436d3e34 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/src/grep.c b/src/grep.c
index e5152bc1..c4ee5bc8 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -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)
{