You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
grep - -E rejects a repeat operator right after ^ or $ (^*, $*, ^+x) #206
In an extended regexp GNU grep accepts a repetition operator that follows an anchor. After ^ it warns * at start of expression (or +, ?) and searches; after $ it accepts it
silently. uu_grep exits 2 with Oniguruma's target of repeat operator is invalid.
Related: #164 covers an operator after ( or |, and #48 strips one at the very start of
the pattern; neither handles an operator after an anchor (Oniguruma reports a different error
code there).
Exposed by the GNU tests spencer1 (tests #53^* and #54$*) and spencer1-locale
(the same two tests in each locale, #209-#216).
Reproduction
Rust (incorrect)
$ printf'q\n'| ./target/release/grep -E '^*q'
grep: invalid pattern "^*q": target of repeat operator is invalid
# Exit code: 2
$ printf'q\n'| ./target/release/grep -E 'q$*'
grep: invalid pattern "q$*": target of repeat operator is invalid
# Exit code: 2
$ printf'q\n'| ./target/release/grep -E '(^+q)'
grep: invalid pattern "(^+q)": target of repeat operator is invalid
# Exit code: 2
#[test]fnere_repeat_after_anchor(){let(_s,mut c) = ucmd();
c.args(&["-E","^*jo"]).pipe_in("jo\nx\n").succeeds().stdout_is("jo\n").stderr_contains("* at start of expression");let(_s,mut c) = ucmd();
c.args(&["-E","jo$+"]).pipe_in("jo\nx\n").succeeds().stdout_only("jo\n");}
Exposed by the GNU grep test suite: spencer1, spencer1-locale.
Activity