summaryrefslogtreecommitdiff
path: root/src/grep.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-09-18 14:49:51 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-09-18 14:51:53 -0700
commit220bd3882cb32b8830dcc742e46aaa93a8c8f9e5 (patch)
tree300499790d2589710c951d759b6e3454d30de7c1 /src/grep.c
parentb6d95a4e6b57cd260040fb83f828e81b01acd720 (diff)
downloadgrep-220bd3882cb32b8830dcc742e46aaa93a8c8f9e5.tar.gz
grep: "grep '\)'" reports an error again
* src/grep.c (try_fgrep_pattern): With -G, pass \) through to GEAcompile so that it can complain. This fixes an unexpected change in behavior from grep 3.4 and earlier. * tests/filename-lineno.pl: Add tests for this sort of thing.
Diffstat (limited to 'src/grep.c')
-rw-r--r--src/grep.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/grep.c b/src/grep.c
index d1ea5daf..3b40bbb7 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -2419,6 +2419,8 @@ try_fgrep_pattern (int matcher, char *keys, size_t *len_p)
goto fail;
case '(': case '+': case '?': case '{': case '|':
+ /* There is no "case ')'" here, as "grep -E ')'" acts like
+ "grep -E '\)'". */
if (matcher != G_MATCHER_INDEX)
goto fail;
break;
@@ -2435,6 +2437,10 @@ try_fgrep_pattern (int matcher, char *keys, size_t *len_p)
goto fail;
case '(': case '+': case '?': case '{': case '|':
+ /* Pass '\)' to GEAcompile so it can complain. Otherwise,
+ "grep '\)'" would act like "grep ')'" while "grep '.*\)'
+ would be an error. */
+ case ')':
if (matcher == G_MATCHER_INDEX)
goto fail;
FALLTHROUGH;