On Sat, 2023-09-09 at 19:38 +0200, Omar Polo wrote: > On 2023/09/09 23:51:20 +0800, lux <[email protected]> wrote: > > Github: https://github.com/vrothberg/vgrep > > > > The built-in grep command in OpenBSD is currently not supported, > > but it > > works well with git-grep and ripgrep. I have tested it on AMD64 7.3 > > and > > it works fine for me. > > Haven't tried the port, but have you tried if removing --color from > the grep invocation (using a custom patch) works? Looking at the > code > they use --color=auto which our grep (rightly IMHO) doesn't support, > but quickly looking at the code they don't seem to care about the > escapes being there. > > If you go this route you may also consider changing -Z with --null. > They seem to assume that -Z is to NUL terminate the file names, while > in our and other grep(1) implementations is to force grep to behave > as > zgrep, we have --null for that. IIUC --null is more portable than - > Z. > >
Thank you, I've made a patch to remove the --color parameter but still
retain the -Z parameter. However, using the --null parameter caused the
original program's output to be misaligned. Now the program works fine.
Here's the patch content:
Index: vgrep.go
--- vgrep.go.orig
+++ vgrep.go
@@ -311,10 +311,9 @@ func (v *vgrep) grep(args []string) {
cmd = append(cmd, args...)
greptype = GITGrep
} else {
- env =
"GREP_COLORS='ms=01;31:mc=:sl=:cx=:fn=:ln=:se=:bn='"
- cmd = []string{"grep", "-ZHInr", "--color=always"}
+ cmd = []string{"grep", "-ZHInr"}
cmd = append(cmd, args...)
- greptype = v.getGrepType()
+ greptype = "BSD"
}
output, err := v.runCommand(cmd, env)
if err != nil {
vgrep.tar.gz
Description: application/compressed-tar
