From: Sergey Matveev Date: Mon, 14 Dec 2020 16:40:11 +0000 (+0300) Subject: Print found .do X-Git-Tag: v0.5.0~3 X-Git-Url: http://www.git.cypherpunks.ru/?p=goredo.git;a=commitdiff_plain;h=601f58169f450ccfeba72394eac549c4f412ab82 Print found .do Previously only non-existent ones were printed out. --- diff --git a/main.go b/main.go index 6cda53e..afed8e0 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,7 @@ import ( "path" "path/filepath" "strconv" + "strings" "go.cypherpunks.ru/recfile" "golang.org/x/sys/unix" @@ -250,9 +251,8 @@ CmdSwitch: break } os.Remove(fdTmp.Name()) - var doFile string cwd, tgt := cwdAndTgt(tgts[0]) - doFile, _, err = findDo(fdTmp, cwd, tgt) + doFile, upLevels, err := findDo(fdTmp, cwd, tgt) if err != nil { break } @@ -271,7 +271,11 @@ CmdSwitch: } fmt.Println(cwdMustRel(cwd, m["Target"])) } - ok = doFile != "" + if doFile == "" { + ok = false + } else { + fmt.Println(path.Join(strings.Repeat("..", upLevels), doFile)) + } default: log.Fatalln("unknown command", cmdName) }