Skip to content

GNU start/end-of-buffer anchors are treated as literals instead of anchors #33

Closed

Description

@sylvestre

GNU grep supports two buffer anchors: \` matches the start of the buffer and \' matches the end (per line, in grep's line-oriented model these behave like ^/$). uu_grep does not recognise them — it treats \` and \' as the literal characters ` and ', so a pattern like t\' matches nothing instead of a line ending in t.

Found by the differential fuzzer (fuzz_grep).

Rust (incorrect)

$ printf 'cat\ndog\n' | ./target/release/grep -e "t\\'"
# Output: (none)
# Exit code: 1

GNU (correct)

$ printf 'cat\ndog\n' | LC_ALL=C /usr/bin/grep -e "t\\'"
cat
# Exit code: 0

The start-of-buffer anchor behaves the same way: \`c matches cat in GNU but nothing in uu_grep.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions