Skip to content

Many shell tests do not escape regular expression meta-characters properly #5915

@chrisd8088

Description

@chrisd8088

Describe the issue

As mentioned in #5914 (comment), we have a fairly large number of places in our test suite where we perform grep(1) commands using regular expressions in which we have not fully escaped all the meta-characters like . and *.

For instance, this check in a test from t/t-migrate-export.sh aims to confirm that git lfs track outputs the expected "*.jpg" already supported message:

git lfs track "*.jpg" | grep "\"*.jpg\" already supported"

However, this would match if the message contained the string XYZjpg" already supported or Zjpg" already supported (but not jpg" already supported) because the "* matches zero or more " characters, and the . matches any character.

System environment

The examples above were performed on macOS, but should behave the same way on any platform.

Output of git lfs env

git-lfs/3.5.1 (GitHub; darwin arm64; go 1.22.1)
git version 2.47.0

Additional context

There are a significant number of these kinds of oversights in our tests' regular expressions, mostly involving meta-characters like . and *, since those are frequently used in filenames and shell wildcards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Bugs

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions