diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2020-09-18 14:49:51 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2020-09-18 14:51:53 -0700 |
commit | 220bd3882cb32b8830dcc742e46aaa93a8c8f9e5 (patch) | |
tree | 300499790d2589710c951d759b6e3454d30de7c1 /src/grep.c | |
parent | b6d95a4e6b57cd260040fb83f828e81b01acd720 (diff) | |
download | grep-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.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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; |