We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent decd3cb commit 4224ef9Copy full SHA for 4224ef9
1 file changed
cmd/grepturbo/main.go
@@ -30,6 +30,7 @@ package main
30
import (
31
"fmt"
32
"os"
33
+ "path/filepath"
34
35
"github.com/spf13/cobra"
36
@@ -198,8 +199,13 @@ func runSearch(idxDir, pattern string) error {
198
199
os.Exit(1) // grep convention: exit 1 when no matches
200
}
201
202
+ root := r.Meta.RootDir
203
for _, m := range matches {
- fmt.Printf("%s:%d:%s\n", m.File, m.Line, m.Text)
204
+ rel, err := filepath.Rel(root, m.File)
205
+ if err != nil {
206
+ rel = m.File
207
+ }
208
+ fmt.Printf("%s:%d:%s\n", rel, m.Line, m.Text)
209
210
return nil
211
0 commit comments