Skip to content

Fix RegEx for grep type#162

Merged
vrothberg merged 1 commit intovrothberg:mainfrom
n-thumann:fix_regex
Oct 31, 2021
Merged

Fix RegEx for grep type#162
vrothberg merged 1 commit intovrothberg:mainfrom
n-thumann:fix_regex

Conversation

@n-thumann
Copy link
Copy Markdown
Contributor

This PR fixes compatibility issues with grep on macOS.
Because macOS uses grep (BSD grep, GNU compatible) 2.6.0-FreeBSD, the RegEx for detecting the version doesn't work as expected.
I therefore removed the matching of the closing bracket ()) and added this different version string as a comment.

Before:

# vgrep -w "Homebrew" --no-less .          
panic: runtime error: index out of range [1] with length 0

goroutine 1 [running]:
main.(*vgrep).getGrepType(0x6542da0)
        /private/tmp/vgrep-20211031-92807-9uidb/vgrep-2.5.3/vgrep.go:264 +0xc8
main.(*vgrep).grep(0xc0000f8000, {0xc00007a040, 0x3, 0x4})
        /private/tmp/vgrep-20211031-92807-9uidb/vgrep-2.5.3/vgrep.go:304 +0x43b
main.main()
        /private/tmp/vgrep-20211031-92807-9uidb/vgrep-2.5.3/vgrep.go:184 +0x765

After (expected result):

# vgrep -w "Homebrew" --no-less .
Index File         Line Content
    0 ./test.txt:1    1 Hello from Homebrew

Copy link
Copy Markdown
Owner

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks a lot for contributing!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants